From teekaysoh at gmail.com Sun Nov 4 05:15:40 2007 From: teekaysoh at gmail.com (TK Soh) Date: Sun, 4 Nov 2007 04:15:40 +0000 Subject: [python-win32] sys.stdout.closed missing with win32trace Message-ID: <58b84f8e0711032115v12864041h61d77282d4b3f37d@mail.gmail.com> It looks like the "closed" attribute for sys.stderr and sys.stdout are missing when win32trace is in effect. Any way to work around this? python script: -------------------------- import win32traceutil import sys if not sys.stdout.closed: print "stdout is opened" -------------------------- Trace collector output: -------------------------- Traceback (most recent call last): File "try.py", line 3, in if not sys.stdout.closed: AttributeError: 'PyTraceObject' object has no attribute 'closed' From fuzzyman at voidspace.org.uk Sun Nov 4 11:21:01 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 04 Nov 2007 10:21:01 +0000 Subject: [python-win32] sys.stdout.closed missing with win32trace In-Reply-To: <58b84f8e0711032115v12864041h61d77282d4b3f37d@mail.gmail.com> References: <58b84f8e0711032115v12864041h61d77282d4b3f37d@mail.gmail.com> Message-ID: <472D9D0D.6040106@voidspace.org.uk> TK Soh wrote: > It looks like the "closed" attribute for sys.stderr and sys.stdout are > missing when win32trace is in effect. Any way to work around this? > I have no idea about win32traceutil, but the sys module provides sys.__stdout__ and sys.__stderr__ so that even when modules replace the streams with custom objects you can still access the originals. This may or may not be helpful... Michael Foord http://www.manning.com/foord > python script: > -------------------------- > import win32traceutil > import sys > if not sys.stdout.closed: > print "stdout is opened" > -------------------------- > > Trace collector output: > -------------------------- > Traceback (most recent call last): > File "try.py", line 3, in > if not sys.stdout.closed: > AttributeError: 'PyTraceObject' object has no attribute 'closed' > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From teekaysoh at gmail.com Sun Nov 4 12:49:49 2007 From: teekaysoh at gmail.com (TK Soh) Date: Sun, 4 Nov 2007 11:49:49 +0000 Subject: [python-win32] sys.stdout.closed missing with win32trace In-Reply-To: <472D9D0D.6040106@voidspace.org.uk> References: <58b84f8e0711032115v12864041h61d77282d4b3f37d@mail.gmail.com> <472D9D0D.6040106@voidspace.org.uk> Message-ID: <58b84f8e0711040349xe17b96fi6af54f592541365b@mail.gmail.com> On 11/4/07, Michael Foord wrote: > TK Soh wrote: > > It looks like the "closed" attribute for sys.stderr and sys.stdout are > > missing when win32trace is in effect. Any way to work around this? > > > > I have no idea about win32traceutil, but the sys module provides > sys.__stdout__ and sys.__stderr__ so that even when modules replace the > streams with custom objects you can still access the originals. This may > or may not be helpful... Thanks for the inform. I am actually calling some library that does the checking on closed attribute. It's be nice to be able to somehow add the closed attribute to win32trace. From teekaysoh at gmail.com Mon Nov 5 10:09:13 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 5 Nov 2007 09:09:13 +0000 Subject: [python-win32] COM server support on Vista Message-ID: <58b84f8e0711050109t473f5bf3rf33156f95bc133@mail.gmail.com> I was wondering if the COM server support in pythonwin works the same way on Vista. I was informed that the Explorer shell extension I wrote on XP does not function when installed on Vista. Just want to find if there's any known bug on Vista. Thanks. From mc at mclaveau.com Mon Nov 5 21:26:34 2007 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 5 Nov 2007 21:26:34 +0100 Subject: [python-win32] COM server support on Vista In-Reply-To: <58b84f8e0711050109t473f5bf3rf33156f95bc133@mail.gmail.com> References: <58b84f8e0711050109t473f5bf3rf33156f95bc133@mail.gmail.com> Message-ID: <3D0CF802BB2B4EFB97686A335C13AE07@MCI1330> Hi! My COM servers, in Python, run without problem on Vista. I had also try : plug-in in Internet-Explorer ; plug-in in Excel. All is OK. @-salutations Michel Claveau From nytrokiss at gmail.com Mon Nov 5 23:58:28 2007 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 5 Nov 2007 23:58:28 +0100 Subject: [python-win32] COM server support on Vista In-Reply-To: <3D0CF802BB2B4EFB97686A335C13AE07@MCI1330> References: <58b84f8e0711050109t473f5bf3rf33156f95bc133@mail.gmail.com> <3D0CF802BB2B4EFB97686A335C13AE07@MCI1330> Message-ID: <8a6b8e350711051458o35b5aab8hd78229a97b5e880c@mail.gmail.com> all fine on my end...! On 11/5/07, Michel Claveau wrote: > > Hi! > > My COM servers, in Python, run without problem on Vista. I had also try : > plug-in in Internet-Explorer ; plug-in in Excel. All is OK. > > @-salutations > > Michel Claveau > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com/ http://www.jewelerslounge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071105/4dce712a/attachment.htm From Brad.Johnson at ballardtech.com Tue Nov 6 23:24:13 2007 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Tue, 6 Nov 2007 22:24:13 +0000 (UTC) Subject: [python-win32] C++ thread cannot acquire GIL Message-ID: I am embedding a Python interpreter in a C++ app for Windows. The main thread in my application calls PyEval_InitThreads(); At some point, the main thread creates a new thread to do some concurrent work using the Python interpreter. The trouble is that in my worker thread I am never able to complete the call PyEval_AcquireLock(), since something else must be holding the GIL (Python gets stuck in the WaitForSingleObject call) I cannot figure out what is holding the GIL, and believe me I've looked. Any debugging tips or glaring errors in my methodology? Thanks! From sean729 at gmail.com Wed Nov 7 05:20:30 2007 From: sean729 at gmail.com (Sean Peterson) Date: Tue, 06 Nov 2007 23:20:30 -0500 Subject: [python-win32] NetUseAdd() and DFS roots Message-ID: <47313D0E.4050209@gmail.com> Has anyone mapped a share via a DFS link using NetUseAdd()? This is my scenario: \\NTS-03.central.purdue.lcl\MI is a DFS link on a Win2003 Server that transparently redirects clients to \\itifs03.itap.purdue.edu\itea_zonedirs\MI import win32net # this works -- win32net.NetUseAdd(None,1,{'remote':r'//itifs03.itap.purdue.edu/itea_zonedirs/MI/TEAMDIRS/DCS Zone','local':'W:'}) # this doesn't work -- win32net.NetUseAdd(None,1,{'remote':r'//NTS-03.central.purdue.lcl/MI/TEAMDIRS/DCS Zone','local':'W:'}) Any help greatly appreciated. -Sean. From Andrew.MACKEITH at 3ds.com Thu Nov 8 04:45:08 2007 From: Andrew.MACKEITH at 3ds.com (MACKEITH Andrew) Date: Wed, 7 Nov 2007 22:45:08 -0500 Subject: [python-win32] Creating COM Server Message-ID: I created the COM server examples from chapter 12 of Win32 Programming, but couldn't get them to work unless I had administrator access. Is administrator access a requirement for creating a COM server ? File "DynamicPolicy.py", line 56, in ? win32com.server.register.UseCommandLine(PythonStringModule) File "C:\Python24\Lib\site-packages\win32com\server\register.py", line 483, in UseCommandLine RegisterClasses(*classes, **flags) File "C:\Python24\Lib\site-packages\win32com\server\register.py", line 413, in RegisterClasses addPyComCat, dispatcherSpec, clsctx, addnPath) File "C:\Python24\Lib\site-packages\win32com\server\register.py", line 181, in RegisterServer _set_string(keyNameRoot, desc) File "C:\Python24\Lib\site-packages\win32com\server\register.py", line 32, in _set_stringvalue) pywintypes.error: (5, 'RegSetValue', 'Access is denied.') Best Regards, ________________________________ Andrew MacKeith V5 SIMULIA Expert Applications Office: +1 401276 7128 Andrew.MACKEITH at 3ds.com Dassault Syst?mes | www.3ds.com Visit us at: www.simulia.com SIMULIA - Dassault Systemes Simulia Corp. 166 Valley Street - 02909-2499 PROVIDENCE - USA From mhammond at skippinet.com.au Thu Nov 8 05:58:52 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 8 Nov 2007 15:58:52 +1100 Subject: [python-win32] Creating COM Server In-Reply-To: References: Message-ID: <03f101c821c4$1269f660$373de320$@com.au> > I created the COM server examples from chapter 12 of Win32 Programming, > but couldn't get them to work unless I had administrator access. > Is administrator access a requirement for creating a COM server ? It is. I understand there are now alternatives to registering objects directly in HKEY_CLASSES_ROOT, but its not an itch I've had yet, and its not obvious how I should determine where the correct place to register is (eg, retry after failure, require explicit param, etc) and how this interacts with Vista (where a better solution in some cases will be be to arrange for the installation program to ShellExecute a copy it itself requesting elevation.) I'd welcome a consensus though :) Cheers, Mark From Brad.Johnson at ballardtech.com Fri Nov 9 00:09:58 2007 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Thu, 8 Nov 2007 23:09:58 +0000 (UTC) Subject: [python-win32] C++ thread cannot acquire GIL References: Message-ID: Brad Johnson ballardtech.com> writes: > > I am embedding a Python interpreter in a C++ app for Windows. > > The main thread in my application calls PyEval_InitThreads(); > > At some point, the main thread creates a new thread to do some concurrent work > using the Python interpreter. > > The trouble is that in my worker thread I am never able to complete the call > PyEval_AcquireLock(), since something else must be holding the GIL (Python gets > stuck in the WaitForSingleObject call) > > I cannot figure out what is holding the GIL, and believe me I've looked. Any > debugging tips or glaring errors in my methodology? > > Thanks! > Just a follow-up, I've found a solution to this problem. Apparently, I was running into a known bug with the Python C API reported here http://bugs.python.org/issue1720250. The workaround is also posted here. I hope this is helpful for posterity that may run into this in the future. From Andrew.MACKEITH at 3ds.com Fri Nov 9 19:57:37 2007 From: Andrew.MACKEITH at 3ds.com (MACKEITH Andrew) Date: Fri, 9 Nov 2007 13:57:37 -0500 Subject: [python-win32] Compiling win32 extensions Message-ID: I am compiling the win32 extensions on 32 bit windows using Microsoft Visual Studio 8 (AKA .Net 2005) I have had some problems with paths, but managed to solve these by manually adding paths to the registry. (I am puzzled that dsound.h appears in the SDK for ce, but not the regular SDK.) I am now stumped by these (related) compile errors. win32apimodule.cpp win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1451) : error C2664: 'PyUnicodeUCS2_FromUnicode' : cannot convert parameter 1 from 'wchar_t [260]' to 'const Py_UNICODE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1975) : error C2664: 'DWORD (LPCWSTR,LPWSTR,DWORD)' : cannot convert parameter 2 from 'Py_UNICODE *' to 'LPWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Are these new errors in Visual Studio 8? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071109/7e391dec/attachment.htm From matherbe at cisco.com Fri Nov 9 21:10:46 2007 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Fri, 9 Nov 2007 15:10:46 -0500 Subject: [python-win32] Automating logon/logoff In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C044E2CB3@xmb-rtp-20b.amer.cisco.com> Message-ID: <249A89BAA060C94FA0B93EA6135CC93C046CE9ED@xmb-rtp-20b.amer.cisco.com> > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Matt > Herbert (matherbe) > Sent: Wednesday, October 17, 2007 11:02 AM > > I am stumped trying to figure out how I can automate the login/logoff > procedure on Windows. > [...] the hard part that I can't figure out, is how do I programmatically > initiate a logon, after a logoff? Hello all, So I got busy doing other things, and I just got back to this earlier this week. I thought that I would post back to the list with my results. It turns out the only way I was able to find to do this, was through GUI automation. After studying some of the open source VNC code, I was able to figure out how to switch desktop's to the 'Winlogon' desktop and send a ctrl-alt-del key sequence. From there, it was a relatively simple matter of using the winGuiAuto.py code (freely available on the internet) to grab the handle of the logon box, find the handles of the username and password entries, stuff my username and password into the entries, then click the ok button. Of course none of that can work, unless you are running as the SYSTEM user, because it seems even Administrator users to not have the correct permissions to access the Winlogon desktop. I can post some sample code, if anybody is curious. -Matt From matherbe at cisco.com Fri Nov 9 21:25:51 2007 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Fri, 9 Nov 2007 15:25:51 -0500 Subject: [python-win32] Logging off of windows Message-ID: <249A89BAA060C94FA0B93EA6135CC93C046CE9F9@xmb-rtp-20b.amer.cisco.com> Hello all, I'm having a little problem figuring how I can tell if there is anybody currently logged into windows at the desktop. More specifically, I am initiating a logoff via the ExitWindowsEx() function and, as we all know, it can sometimes take a little bit for the logoff to actually complete (my system takes anywhere from 3 to 20 seconds). The problem is ExitWindowsEx() return's immediately. But I don't want to do anything until the logoff process has completed and we are sitting happily at the logon screen. So just to give a little perspective on this, I have a service that runs all the time, for automated testing. The service need's to perform some test's at the desktop, and other tests at the logon screen. I need to be sure, that after I've logged a user off, that the logoff process has completed, and we are indeed at the logon screen. I have tried using: deskh = win32service.GetThreadDesktop(win32api.GetCurrentThreadId()) name = win32service.GetUserObjectInformation(deskh,win32service.UOI_NAME) but that always returns "Default", even after the user has logged out. I'm not really sure where to go next. Do any of you very smart people have any good idea's on how I can solve this problem? -Matt From rwupole at msn.com Sun Nov 11 07:21:21 2007 From: rwupole at msn.com (Roger Upole) Date: Sun, 11 Nov 2007 01:21:21 -0500 Subject: [python-win32] Logging off of windows Message-ID: Matt Herbert wrote: > > Hello all, > > I'm having a little problem figuring how I can tell if there is anybody > currently logged into windows at the desktop. More specifically, I am > initiating a logoff via the ExitWindowsEx() function and, as we all > know, it can sometimes take a little bit for the logoff to actually > complete (my system takes anywhere from 3 to 20 seconds). > > The problem is ExitWindowsEx() return's immediately. But I don't want to > do anything until the logoff process has completed and we are sitting > happily at the logon screen. > > So just to give a little perspective on this, I have a service that runs > all the time, for automated testing. The service need's to perform some > test's at the desktop, and other tests at the logon screen. I need to be > sure, that after I've logged a user off, that the logoff process has > completed, and we are indeed at the logon screen. > > I have tried using: > > deskh = win32service.GetThreadDesktop(win32api.GetCurrentThreadId()) > name = > win32service.GetUserObjectInformation(deskh,win32service.UOI_NAME) This will return information for the desktop on which the service is running, which is usually not the interactive desktop. Both are named Default, but exist in different window stations. In fact, on Vista services run in an entirely separate session from the interactive session, and interacting with it is restricted. > but that always returns "Default", even after the user has logged out. > I'm not really sure where to go next. > > Do any of you very smart people have any good idea's on how I can solve > this problem? > > -Matt You may be able to use win32ts.WTSEnumerateSessions to check if the console session is currently active. Roger From kf9150 at gmail.com Tue Nov 13 19:03:59 2007 From: kf9150 at gmail.com (Kelie) Date: Tue, 13 Nov 2007 18:03:59 +0000 (UTC) Subject: [python-win32] problem creating a simple COM server Message-ID: Hello group, Following the example in Mark's book, I tried creating a simple COM server exposing two methods from the re module. But could not get it to work. Here is the code: class PythonModule_re: _public_methods_ = ['pyfindall', 'pysplit'] _reg_progid_ = "PythonModule.re" # NEVER copy the following ID # Use "print pythoncom.CreateGuid()" to make a new one. _reg_clsid_ = "{770E12AD-FED0-47C1-8457-E737FE6F5843}" def pyfindall(self, pat, s): import re return re.findall(re.compile(pat), s) def pysplit(self, pat, s): import re return re.split(re.compile(pat), s) if __name__=='__main__': print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(PythonModule_re) This is the vba code to test the COM server from which I got an error saying "Objects doesn't support this property or method." Public Sub Test() Dim pyRegex As Object Dim r1 As Variant Dim r2 As Variant Set pyRegex = CreateObject("PythonModule.re") r1 = pyRegex.pyfindall("\d", "a1b2c3") r2 = pyRegex.pysplit("\d", "a1b2c3") Debug.Print "Done." End Sub The odd thing (to me) was if I rename the function pyfindall to findall, it works. But I could not do that with pysplit because there is a vb function called Split. Any hints? Thanks a lot! - kelie From matherbe at cisco.com Tue Nov 13 21:36:36 2007 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Tue, 13 Nov 2007 15:36:36 -0500 Subject: [python-win32] Logging off of windows In-Reply-To: Message-ID: <249A89BAA060C94FA0B93EA6135CC93C04728DD4@xmb-rtp-20b.amer.cisco.com> Thanks Roger, That worked perfectly! import win32ts for s in win32ts.WTSEnumerateSessions(win32ts.WTSOpenServer("."),1): if s['State'] == win32ts.WTSActive: print "Session is active" -Matt > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Roger Upole > Sent: Sunday, November 11, 2007 1:21 AM > To: python-win32 at python.org > Subject: [python-win32] Logging off of windows > > Matt Herbert wrote: > > > > Hello all, > > > > I'm having a little problem figuring how I can tell if > there is anybody > > currently logged into windows at the desktop. More > specifically, I am > > initiating a logoff via the ExitWindowsEx() function and, as we all > > know, it can sometimes take a little bit for the logoff to actually > > complete (my system takes anywhere from 3 to 20 seconds). > > > > The problem is ExitWindowsEx() return's immediately. But I > don't want to > > do anything until the logoff process has completed and we > are sitting > > happily at the logon screen. > > > > So just to give a little perspective on this, I have a > service that runs > > all the time, for automated testing. The service need's to > perform some > > test's at the desktop, and other tests at the logon screen. > I need to be > > sure, that after I've logged a user off, that the logoff process has > > completed, and we are indeed at the logon screen. > > > > I have tried using: > > > > deskh = win32service.GetThreadDesktop(win32api.GetCurrentThreadId()) > > name = > > win32service.GetUserObjectInformation(deskh,win32service.UOI_NAME) > > This will return information for the desktop on which the > service is running, which > is usually not the interactive desktop. Both are named > Default, but exist in different > window stations. In fact, on Vista services run in an > entirely separate session > from the interactive session, and interacting with it is restricted. > > > but that always returns "Default", even after the user has > logged out. > > I'm not really sure where to go next. > > > > Do any of you very smart people have any good idea's on how > I can solve > > this problem? > > > > -Matt > > You may be able to use win32ts.WTSEnumerateSessions to check if the > console session is currently active. > > Roger > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From larry.bates at websafe.com Tue Nov 13 22:51:38 2007 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 13 Nov 2007 15:51:38 -0600 Subject: [python-win32] problem creating a simple COM server In-Reply-To: References: Message-ID: <473A1C6A.4030607@websafe.com> Kelie wrote: > Hello group, > > Following the example in Mark's book, I tried creating a simple COM server > exposing two methods from the re module. But could not get it to work. Here is > the code: > > class PythonModule_re: > _public_methods_ = ['pyfindall', 'pysplit'] > _reg_progid_ = "PythonModule.re" > # NEVER copy the following ID > # Use "print pythoncom.CreateGuid()" to make a new one. > _reg_clsid_ = "{770E12AD-FED0-47C1-8457-E737FE6F5843}" > > def pyfindall(self, pat, s): > import re > return re.findall(re.compile(pat), s) > > def pysplit(self, pat, s): > import re > return re.split(re.compile(pat), s) > > if __name__=='__main__': > print "Registering COM server..." > import win32com.server.register > win32com.server.register.UseCommandLine(PythonModule_re) > > This is the vba code to test the COM server from which I got an error saying > "Objects doesn't support this property or method." > > Public Sub Test() > Dim pyRegex As Object > Dim r1 As Variant > Dim r2 As Variant > > Set pyRegex = CreateObject("PythonModule.re") > r1 = pyRegex.pyfindall("\d", "a1b2c3") > r2 = pyRegex.pysplit("\d", "a1b2c3") > Debug.Print "Done." > End Sub > > The odd thing (to me) was if I rename the function pyfindall to findall, it > works. But I could not do that with pysplit because there is a vb function > called Split. > > Any hints? Thanks a lot! > > - kelie I made the following small changes (but only to the VB program) and it runs without any errors for me: Public Sub Test() Dim pyRegex As Object Dim r1 As Variant Dim r2 As Variant MsgBox "entering test" Set pyRegex = CreateObject("PythonModule.re") MsgBox "Created instance of pyRegex" MsgBox "Calling pyfindall" r1 = pyRegex.pyfindall("\d", "a1b2c3") MsgBox "Calling pysplit" r2 = pyRegex.pysplit("\d", "a1b2c3") MsgBox "Done." End Sub -Larry From kf9150 at gmail.com Tue Nov 13 23:50:20 2007 From: kf9150 at gmail.com (Kelie) Date: Tue, 13 Nov 2007 22:50:20 +0000 (UTC) Subject: [python-win32] problem creating a simple COM server References: <473A1C6A.4030607@websafe.com> Message-ID: Larry Bates websafe.com> writes: > I made the following small changes (but only to the VB program) and it runs > without any errors for me: > > -Larry > Larry, Thanks for your reply. I'm getting the same error with your revised code. Other than adding MsgBox calls, did you make other changes? From mc at mclaveau.com Wed Nov 14 07:32:30 2007 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 14 Nov 2007 07:32:30 +0100 Subject: [python-win32] problem creating a simple COM server In-Reply-To: References: <473A1C6A.4030607@websafe.com> Message-ID: Hi! With this Python's script : import win32com.client pyRegex = win32com.client.Dispatch('PythonModule.re') r1 = pyRegex.pyfindall("\\d", "a1b2c3") print r1 r2 = pyRegex.pysplit("\\d", "a1b2c3") print r2 Your code run OK. Therefore the problem is on your VBA side. And, sorry, I can't try that. But, are you sure than the (VBA-host) application can support Unicode return by your Python-COM-server? @+ Michel Claveau From torerik81 at gmail.com Wed Nov 14 16:05:39 2007 From: torerik81 at gmail.com (=?ISO-8859-1?Q?Tor_Erik_S=F8nvisen?=) Date: Wed, 14 Nov 2007 16:05:39 +0100 Subject: [python-win32] win32 and .NET Message-ID: <96f089100711140705o3ce680a9ma0e0e913e53f396e@mail.gmail.com> Hi, Just wanted to know if it's possible to access .NET using win32 for python. -Tor Erik From mc at mclaveau.com Wed Nov 14 16:38:22 2007 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 14 Nov 2007 16:38:22 +0100 Subject: [python-win32] win32 and .NET In-Reply-To: <96f089100711140705o3ce680a9ma0e0e913e53f396e@mail.gmail.com> References: <96f089100711140705o3ce680a9ma0e0e913e53f396e@mail.gmail.com> Message-ID: <40A61E98130B414892E405B00C733FAD@MCI1330> Hi! For access to dotNET resources from Python, a good way : http://sourceforge.net/projects/pythonnet/ @+ Michel Claveau From kf9150 at gmail.com Wed Nov 14 17:47:39 2007 From: kf9150 at gmail.com (Kelie) Date: Wed, 14 Nov 2007 16:47:39 +0000 (UTC) Subject: [python-win32] problem creating a simple COM server References: <473A1C6A.4030607@websafe.com> Message-ID: Michel Claveau mclaveau.com> writes: > Your code run OK. Therefore the problem is on your VBA side. > And, sorry, I can't try that. But, are you sure than the (VBA-host) > application can support Unicode return by your Python-COM-server? > > @+ > > Michel Claveau > Thanks Michel. I don't know what happened. But the code runs fine today. The only possible reason is that I rebooted my computer yesterday. From nytrokiss at gmail.com Wed Nov 14 17:50:58 2007 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 14 Nov 2007 17:50:58 +0100 Subject: [python-win32] win32 and .NET In-Reply-To: <40A61E98130B414892E405B00C733FAD@MCI1330> References: <96f089100711140705o3ce680a9ma0e0e913e53f396e@mail.gmail.com> <40A61E98130B414892E405B00C733FAD@MCI1330> Message-ID: <8a6b8e350711140850u29e7ca6dj1e0706b3ea8bb31c@mail.gmail.com> You can also try IronPython On Nov 14, 2007 4:38 PM, Michel Claveau wrote: > Hi! > > For access to dotNET resources from Python, a good way : > http://sourceforge.net/projects/pythonnet/ > > @+ > > Michel Claveau > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com/movado--watches.html http://www.jewelerslounge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071114/7f4d65e7/attachment.htm From mc at mclaveau.com Thu Nov 15 07:39:29 2007 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 15 Nov 2007 07:39:29 +0100 Subject: [python-win32] win32 and .NET In-Reply-To: <8a6b8e350711140850u29e7ca6dj1e0706b3ea8bb31c@mail.gmail.com> References: <96f089100711140705o3ce680a9ma0e0e913e53f396e@mail.gmail.com> <40A61E98130B414892E405B00C733FAD@MCI1330> <8a6b8e350711140850u29e7ca6dj1e0706b3ea8bb31c@mail.gmail.com> Message-ID: Hi! > James Matthews : > You can also try IronPython Yes, IronPython is a good software. But WARNING: IronPython (IP) is really different: IP don't run Pywin32 ; IP don't run normal Python environment ; IP don't run many modules / libraries / your (actually) scripts. AMHA, IP est good... if you (re)-start from zero. @-salutations Michel Claveau From sten at blinkenlights.nl Thu Nov 15 16:20:53 2007 From: sten at blinkenlights.nl (Sten Spans) Date: Thu, 15 Nov 2007 16:20:53 +0100 (CET) Subject: [python-win32] Delete IIS website via wmi Message-ID: I'm rewriting some iis management scripts in python, using the python wmi bindings from http://tgolden.sc.sabren.com/python/wmi.html Creating / Ennumerating sites works just fine. But I can't seem to figure out how to delete sites. import wmi iis = wmi.WMI(namespace = "MicrosoftIISv2") ''' locate a the first website''' website = iis.IIsWebServerSetting()[0] ''' locate it's webserver ''' webserver = iis.IIsWebServer(Name="%s" % website.name)[0] ''' stop the webserver ''' webserver.Stop() ''' delete the website ''' website.Delete() results in: D:\test>c:\Python25\python.exe test.py Traceback (most recent call last): File "test.py", line 16, in website.Delete() File "c:\Python25\Lib\site-packages\wmi.py", line 472, in __getattr__ return getattr (self.ole_object, attribute) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: .Delete Any hints ? -- Sten Spans "There is a crack in everything, that's how the light gets in." Leonard Cohen - Anthem From timr at probo.com Thu Nov 15 20:27:53 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 15 Nov 2007 11:27:53 -0800 Subject: [python-win32] win32 and .NET In-Reply-To: References: <96f089100711140705o3ce680a9ma0e0e913e53f396e@mail.gmail.com> <40A61E98130B414892E405B00C733FAD@MCI1330> <8a6b8e350711140850u29e7ca6dj1e0706b3ea8bb31c@mail.gmail.com> Message-ID: <473C9DB9.5070808@probo.com> Michel Claveau wrote: > >> James Matthews : >> You can also try IronPython >> > > Yes, IronPython is a good software. > > But WARNING: > IronPython (IP) is really different: IP don't run Pywin32 ; IP don't run > normal Python environment ; IP don't run many modules / libraries / your > (actually) scripts. > > AMHA, IP est good... if you (re)-start from zero. Yes. If you go in expecting IronPython to be a different spin on CPython, you will be disappointed. Most Python-only modules work; anything with a C component doesn't. However, if you go in expecting IronPython to be a gateway into the world of .NET programming, allowing you to exploit the CLR while using your favorite language instead of having to learn C#, then you will be pleased. Someone just this week posted a IronPython add-in intended to allow CPython C modules to work, so the level of compatibility may be rising. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From lakki712 at gmail.com Fri Nov 16 08:13:37 2007 From: lakki712 at gmail.com (lakki p) Date: Fri, 16 Nov 2007 12:43:37 +0530 Subject: [python-win32] Regarding Extending python in C Message-ID: <7d95ff950711152313n56cc9810k8fc1dc98677e93a2@mail.gmail.com> Hi Guys, please give me the EXACT PROCEDURE with suitable EXAMPLE. i tired but am getting error like: unable to open wchar.h Thanks, lakki -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071116/2c702784/attachment.htm From singhai.nish at gmail.com Fri Nov 16 09:43:12 2007 From: singhai.nish at gmail.com (kNish) Date: Fri, 16 Nov 2007 14:13:12 +0530 Subject: [python-win32] cgi fieldstorage Message-ID: <81bfef2e0711160043s4f25a3c8r5a5598256f3ca62b@mail.gmail.com> Hi, to get a text field value from a php page, getvalue function is used. . . form = cgi.FieldStorage() artist = form.getvalue('artist') To get a value from a drop down box, what function should be used. bRgds, kNish From sten at blinkenlights.nl Fri Nov 16 14:45:11 2007 From: sten at blinkenlights.nl (Sten Spans) Date: Fri, 16 Nov 2007 14:45:11 +0100 (CET) Subject: [python-win32] Delete IIS website via wmi In-Reply-To: References: Message-ID: On Thu, 15 Nov 2007, Sten Spans wrote: > > I'm rewriting some iis management scripts in python, > using the python wmi bindings from http://tgolden.sc.sabren.com/python/wmi.html > > Creating / Ennumerating sites works just fine. > But I can't seem to figure out how to delete sites. > > import wmi > > iis = wmi.WMI(namespace = "MicrosoftIISv2") > > ''' locate a the first website''' > website = iis.IIsWebServerSetting()[0] > > ''' locate it's webserver ''' > webserver = iis.IIsWebServer(Name="%s" % website.name)[0] > > ''' stop the webserver ''' > webserver.Stop() > > ''' delete the website ''' > website.Delete() > > results in: > > D:\test>c:\Python25\python.exe test.py > Traceback (most recent call last): > File "test.py", line 16, in > website.Delete() > File "c:\Python25\Lib\site-packages\wmi.py", line 472, in __getattr__ > return getattr (self.ole_object, attribute) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 496, in > __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: .Delete > > > Any hints ? I figured it out by looking at iisweb.vbs, Delete_ does work: def delete_site(self, site): """ stop and delete a website """ for website in self.iis.IIsWebServerSetting(): if site['name'] == website.ServerComment: webserver = self.iis.IIsWebServer(Name=website.Name)[0] webserver.Stop() webserver.Delete_() -- Sten Spans "There is a crack in everything, that's how the light gets in." Leonard Cohen - Anthem From terry6394 at gmail.com Fri Nov 16 17:53:09 2007 From: terry6394 at gmail.com (Cyril.Liu) Date: Sat, 17 Nov 2007 00:53:09 +0800 Subject: [python-win32] How to Get a pixel color? Message-ID: <6d2d06b10711160853g4c6acc95v9ae1540301e16525@mail.gmail.com> *Hello All, I try to get a pixel color according to x,y pixel coordinates using this code, but it doesn't work.* >>> import win32ui >>> w = win32ui.FindWindow(None, "11") >>> dc = w.GetWindowDC() >>> color = dc.GetPixel(100,100) Traceback (most recent call last): File "", line 1, in win32ui: GetPixel failed *I can do it in VC++ like this:* COLORREF GetColor(HWND hWnd, int x, int y) { COLORREF color; HDC hDC = NULL; hDC = GetDC(hWnd); color = GetPixel(hDC, x, y); ReleaseDC(hWnd, hDC); return color; } *bye the way. Where is the** GetPixel(hDC, x, y) like win32SDK in pythonwin? * -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071117/7ab9449e/attachment.htm From timr at probo.com Fri Nov 16 19:09:24 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 16 Nov 2007 10:09:24 -0800 Subject: [python-win32] How to Get a pixel color? In-Reply-To: <6d2d06b10711160853g4c6acc95v9ae1540301e16525@mail.gmail.com> References: <6d2d06b10711160853g4c6acc95v9ae1540301e16525@mail.gmail.com> Message-ID: <473DDCD4.5000800@probo.com> Cyril.Liu wrote: > *Hello All, > I try to get a pixel color according to x,y pixel coordinates using > this code, but it doesn't work.* > > >>> import win32ui > >>> w = win32ui.FindWindow(None, "11") > >>> dc = w.GetWindowDC() > >>> color = dc.GetPixel(100,100) > Traceback (most recent call last): > File "", line 1, in > win32ui: GetPixel failed Are you sure you have a window with the title "11", and that it still existed by the time you called GetPixel? Your example worked perfectly for me. The window was the cmd session where I was typing the commands. The background is dark blue, which is 0x800000. C:\Dev\fx2\sw\linux\include>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32ui >>> w = win32ui.FindWindow( None, "VS8 Build Environment - python" ) >>> dc = w.GetWindowDC() >>> hex(dc.GetPixel( 100,100)) '0x800000' >>> -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Nov 16 19:09:57 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 16 Nov 2007 10:09:57 -0800 Subject: [python-win32] cgi fieldstorage In-Reply-To: <81bfef2e0711160043s4f25a3c8r5a5598256f3ca62b@mail.gmail.com> References: <81bfef2e0711160043s4f25a3c8r5a5598256f3ca62b@mail.gmail.com> Message-ID: <473DDCF5.4080908@probo.com> kNish wrote: > Hi, > > to get a text field value from a php page, getvalue function is used. > > . > . > form = cgi.FieldStorage() > artist = form.getvalue('artist') > Well, that's one way. You can also use form['artist'].value, which is the style I've seen most often. You can use whichever one makes sense to you. > To get a value from a drop down box, what function should be used. > It's exactly the same. HTTP GET and POST data doesn't know what kind of field it was. It's just a list of name=value pairs -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From kxroberto at googlemail.com Fri Nov 16 20:57:32 2007 From: kxroberto at googlemail.com (Robert) Date: Fri, 16 Nov 2007 20:57:32 +0100 Subject: [python-win32] How to get URL of open browser window? Message-ID: What is the best way to get the URL of current open webbrowser Window (topmost) into a utility script? At least for IE & Mozilla's Robert From mhammond at skippinet.com.au Sun Nov 18 03:11:48 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 18 Nov 2007 13:11:48 +1100 Subject: [python-win32] Compiling win32 extensions In-Reply-To: References: Message-ID: <098901c82988$63961390$2ac23ab0$@com.au> Although VS8 is not officially supported and no official binaries are released built with that version, you should find the CVS version of pywin32 builds cleanly with VS8, even if you target x64. Cheers, Mark From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org] On Behalf Of MACKEITH Andrew Sent: Saturday, 10 November 2007 5:58 AM To: python-win32 at python.org Subject: [python-win32] Compiling win32 extensions I am compiling the win32 extensions on 32 bit windows using Microsoft Visual Studio 8 (AKA .Net 2005) I have had some problems with paths, but managed to solve these by manually adding paths to the registry. (I am puzzled that dsound.h appears in the SDK for ce, but not the regular SDK.) I am now stumped by these (related) compile errors. win32apimodule.cpp win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1451) : error C2664: 'PyUnicodeUCS2_FromUnicode' : cannot convert parameter 1 from 'wchar_t [260]' to 'const Py_UNICODE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1975) : error C2664: 'DWORD (LPCWSTR,LPWSTR,DWORD)' : cannot convert parameter 2 from 'Py_UNICODE *' to 'LPWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Are these new errors in Visual Studio 8? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071118/a33c5b8e/attachment.htm From Andrew.MACKEITH at 3ds.com Sun Nov 18 05:01:05 2007 From: Andrew.MACKEITH at 3ds.com (MACKEITH Andrew) Date: Sat, 17 Nov 2007 23:01:05 -0500 Subject: [python-win32] Compiling win32 extensions In-Reply-To: <098901c82988$63961390$2ac23ab0$@com.au> References: <098901c82988$63961390$2ac23ab0$@com.au> Message-ID: ________________________________ From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Saturday, November 17, 2007 9:12 PM To: MACKEITH Andrew; python-win32 at python.org Subject: RE: [python-win32] Compiling win32 extensions Although VS8 is not officially supported and no official binaries are released built with that version, you should find the CVS version of pywin32 builds cleanly with VS8, even if you target x64. Cheers, Mark I downloaded the CVS tree on Nov 9th, and I am building with that. How does LPCWSTR relate to Py_UNICODE? win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Andrew From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org] On Behalf Of MACKEITH Andrew Sent: Saturday, 10 November 2007 5:58 AM To: python-win32 at python.org Subject: [python-win32] Compiling win32 extensions I am compiling the win32 extensions on 32 bit windows using Microsoft Visual Studio 8 (AKA .Net 2005) I have had some problems with paths, but managed to solve these by manually adding paths to the registry. (I am puzzled that dsound.h appears in the SDK for ce, but not the regular SDK.) I am now stumped by these (related) compile errors. win32apimodule.cpp win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1451) : error C2664: 'PyUnicodeUCS2_FromUnicode' : cannot convert parameter 1 from 'wchar_t [260]' to 'const Py_UNICODE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1975) : error C2664: 'DWORD (LPCWSTR,LPWSTR,DWORD)' : cannot convert parameter 2 from 'Py_UNICODE *' to 'LPWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Are these new errors in Visual Studio 8? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071117/2e5ce7a9/attachment.htm From mobiledreamers at gmail.com Sun Nov 18 05:13:10 2007 From: mobiledreamers at gmail.com (mobiledreamers at gmail.com) Date: Sat, 17 Nov 2007 20:13:10 -0800 Subject: [python-win32] Programming Outlook with python Message-ID: Hello I m looking for how to program Outlook with Python Any pointers ? Is it getting easier with Ironpython thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071117/fba06970/attachment.htm From kf9150 at gmail.com Sun Nov 18 08:06:35 2007 From: kf9150 at gmail.com (Kelie) Date: Sun, 18 Nov 2007 07:06:35 +0000 (UTC) Subject: [python-win32] Programming Outlook with python References: Message-ID: gmail.com> writes: > > HelloI m looking for how to program Outlook with PythonAny pointers?Is it getting easier with Ironpython thanks > > _______________________________________________ > python-win32 mailing list > python-win32 python.org > http://mail.python.org/mailman/listinfo/python-win32 > I'd suggest pywin32. Download and install it. Check out the examples. Ask questions. http://sourceforge.net/projects/pywin32/ From simon at brunningonline.net Sun Nov 18 12:24:11 2007 From: simon at brunningonline.net (Simon Brunning) Date: Sun, 18 Nov 2007 11:24:11 +0000 Subject: [python-win32] Programming Outlook with python In-Reply-To: References: Message-ID: <8c7f10c60711180324q2a9427d3sb4361d1b344eb628@mail.gmail.com> On Nov 18, 2007 4:13 AM, wrote: > Hello > I m looking for how to program Outlook with Python > Any pointers If you want an example, you might want to look at the Spambayes Outlook plugin - . -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues From mail at timgolden.me.uk Sun Nov 18 16:27:11 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 18 Nov 2007 15:27:11 +0000 Subject: [python-win32] How to get URL of open browser window? In-Reply-To: References: Message-ID: <474059CF.3020102@timgolden.me.uk> Robert wrote: > What is the best way to get the URL of current open webbrowser > Window (topmost) into a utility script? At least for IE & Mozilla's I don't think that there is a straightforward answer to this question. Assuming you're starting from nothing, there are two issues here: find an open web browser; find out what page that web browser is on. Even if you limit yourself to IE & Firefox (and there are others) you still have to do the "Find a top-level window" dance. What do you do if there is more than one such open? Or if there is one of each? Once you've done that -- say, by choosing the first one you come to -- you then have to adopt multiple strategies for determining the current URL. And the first question is: What is the "current" URL for a browser with multiple tabs. I don't have one to hand, but you examples abound on the Web of finding the top-level window for an application. Modules like pywinauto [1] or WATSUP [2] can probably help you out. Once you've found the window, with IE you should be able to interrogate it via COM. Have a look at PAMIE [3] but I don't think Firefox is COM-scriptable you might have to fallback on pywinauto to interrogate windows class by class to spot the one with the URL in it. TJG [1] http://www.openqa.org/pywinauto/ [2] http://www.tizmoi.net/watsup/intro.html [3] http://pamie.sourceforge.net/ From ghankiewicz at rastertech.es Sun Nov 18 16:25:58 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Sun, 18 Nov 2007 16:25:58 +0100 Subject: [python-win32] Regarding Extending python in C In-Reply-To: <7d95ff950711152313n56cc9810k8fc1dc98677e93a2@mail.gmail.com> References: <7d95ff950711152313n56cc9810k8fc1dc98677e93a2@mail.gmail.com> Message-ID: <47405986.4000508@rastertech.es> lakki p escribi?: > please give me the EXACT PROCEDURE with suitable EXAMPLE. Try this: http://docs.python.org/ext/intro.html > i tired but am getting error like: unable to open wchar.h Your compiler is not finding the header file. Check the documentation provided by your compiler and see how you can specify look up paths for it. -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From mhammond at skippinet.com.au Sun Nov 18 23:08:37 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Nov 2007 09:08:37 +1100 Subject: [python-win32] Compiling win32 extensions In-Reply-To: References: <098901c82988$63961390$2ac23ab0$@com.au> Message-ID: <09ea01c82a2f$98553690$c8ffa3b0$@com.au> Oops - my mistake! Please see pywintypes.h, where you will find a block: // As of Python 2.6, Python switched to 'wchar_t' for unicode. Some old // win32 structures that still use 'unsigned short' now fail from C++ with // VS8 so we provide a couple of helpers. // XXX - but, when trying to use VC2003 with x64, the SDK x64 compiler // reports itself as 14.00.40310.41 - so this breaks under that compiler // Its not clear how to resolve this, but while VS2003 is the default // compiler, that is what must work. #if 0 // and _MSC_VER >= 1400 . Sadly, I can't think of anything to test that works in all cases, so you will need to manually enable that block. Any ideas regarding what to test for would be appreciated. Cheers, Mark From: MACKEITH Andrew [mailto:Andrew.MACKEITH at 3ds.com] Sent: Sunday, 18 November 2007 3:01 PM To: Mark Hammond; python-win32 at python.org Subject: RE: [python-win32] Compiling win32 extensions _____ From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Saturday, November 17, 2007 9:12 PM To: MACKEITH Andrew; python-win32 at python.org Subject: RE: [python-win32] Compiling win32 extensions Although VS8 is not officially supported and no official binaries are released built with that version, you should find the CVS version of pywin32 builds cleanly with VS8, even if you target x64. Cheers, Mark I downloaded the CVS tree on Nov 9th, and I am building with that. How does LPCWSTR relate to Py_UNICODE? win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Andrew From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org] On Behalf Of MACKEITH Andrew Sent: Saturday, 10 November 2007 5:58 AM To: python-win32 at python.org Subject: [python-win32] Compiling win32 extensions I am compiling the win32 extensions on 32 bit windows using Microsoft Visual Studio 8 (AKA .Net 2005) I have had some problems with paths, but managed to solve these by manually adding paths to the registry. (I am puzzled that dsound.h appears in the SDK for ce, but not the regular SDK.) I am now stumped by these (related) compile errors. win32apimodule.cpp win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1451) : error C2664: 'PyUnicodeUCS2_FromUnicode' : cannot convert parameter 1 from 'wchar_t [260]' to 'const Py_UNICODE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1975) : error C2664: 'DWORD (LPCWSTR,LPWSTR,DWORD)' : cannot convert parameter 2 from 'Py_UNICODE *' to 'LPWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Are these new errors in Visual Studio 8? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071119/02533929/attachment.htm From teekaysoh at gmail.com Mon Nov 19 02:04:43 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 19 Nov 2007 01:04:43 +0000 Subject: [python-win32] win32tracutil traceback on Vista Message-ID: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> On Vista, win32tracutil traceback with a "pywintypes.error": >>> import win32traceutil Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\win32\lib\win32traceutil.py", line 53, in SetupForPrint() File "C:\Python25\Lib\site-packages\win32\lib\win32traceutil.py", line 43, in SetupForPrint win32trace.InitWrite() pywintypes.error: (5, 'CreateFileMapping', 'Access is denied.') Any idea where went wrong? Thanks. From charlie at sallyAndCharlie.com Mon Nov 19 03:18:12 2007 From: charlie at sallyAndCharlie.com (Charlie) Date: Mon, 19 Nov 2007 02:18:12 +0000 (UTC) Subject: [python-win32] want to leave DOS console at any target dir Message-ID: When launching a python script from a DOS console, I can not find a way to leave the DOS console at a working directory other than the initial working directory. os.chdir only seems to work for the python script context, not the DOS context. I guess this amounts to a work-around for no "os.fchdir" function in python for Windows. My current approach (which is an eye-sore) is to: 1) Launch a BAT file 2) The BAT file launches my python script 3) the python script creates a 2nd BAT file with a "CD c:\xxx\yyy" command 4) The 1st BAT file calls the 2nd BAT file when the python script terminates. Yikes. Please tell me there's something better. Thanks From mhammond at skippinet.com.au Mon Nov 19 03:31:52 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Nov 2007 13:31:52 +1100 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> Message-ID: <0a0d01c82a54$877f1050$967d30f0$@com.au> > On Vista, win32tracutil traceback with a "pywintypes.error": > > >>> import win32traceutil > Traceback (most recent call last): > File "", line 1, in > File "C:\Python25\Lib\site-packages\win32\lib\win32traceutil.py", > line 53, in > SetupForPrint() > File "C:\Python25\Lib\site-packages\win32\lib\win32traceutil.py", > line 43, in SetupForPrint > win32trace.InitWrite() > pywintypes.error: (5, 'CreateFileMapping', 'Access is denied.') > > > Any idea where went wrong? Thanks. Yes - a user running without elevated credentials can't create objects in the "Global\\" namespace under Vista - which is exactly what win32trace tries to do. This has been fixed in CVS, and I really hope to get a new build out within a couple of weeks. IIRC, a workaround is to start a "reader" process (ie, "python win32traceutil.py") from a command-prompt running elevated (ie, "as Administrator") - a client should then be capable of working without requiring elevated permissions, as the mapping will have been created and permissions adjusted. Cheers, Mark From metolone at hotmail.com Mon Nov 19 09:32:39 2007 From: metolone at hotmail.com (Mark Tolonen) Date: Mon, 19 Nov 2007 00:32:39 -0800 Subject: [python-win32] want to leave DOS console at any target dir References: Message-ID: > Date: Mon, 19 Nov 2007 02:18:12 +0000 (UTC) > From: Charlie > Subject: [python-win32] want to leave DOS console at any target dir > To: python-win32 at python.org > Message-ID: > Content-Type: text/plain; charset=us-ascii > > When launching a python script from a DOS console, > I can not find a way to leave the DOS console at a working directory > other than the initial working directory. > > os.chdir only seems to work for the python script context, not the DOS > context. > > I guess this amounts to a work-around for no "os.fchdir" function in > python for > Windows. > > My current approach (which is an eye-sore) is to: > 1) Launch a BAT file > 2) The BAT file launches my python script > 3) the python script creates a 2nd BAT file with a "CD c:\xxx\yyy" command > 4) The 1st BAT file calls the 2nd BAT file when the python script > terminates. > > Yikes. > > Please tell me there's something better. That's "just the way it works". An executable is created with an initial current directory and can only change its own current directory. The parent executable has its own current directory and it can't be changed by its child processes. The parent has to set up a method for the child to tell it when it wants the parent to change, which is what you've set up in the scenario you described. -Mark From teekaysoh at gmail.com Mon Nov 19 12:49:55 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 19 Nov 2007 19:49:55 +0800 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <0a0d01c82a54$877f1050$967d30f0$@com.au> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> <0a0d01c82a54$877f1050$967d30f0$@com.au> Message-ID: <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> On Nov 19, 2007 10:31 AM, Mark Hammond wrote: > Yes - a user running without elevated credentials can't create objects in > the "Global\\" namespace under Vista - which is exactly what win32trace > tries to do. This has been fixed in CVS, and I really hope to get a new > build out within a couple of weeks. IIRC, a workaround is to start a > "reader" process (ie, "python win32traceutil.py") from a command-prompt > running elevated (ie, "as Administrator") - a client should then be capable > of working without requiring elevated permissions, as the mapping will have > been created and permissions adjusted. Thanks for the tip. Though I'm not sure the workaround will work out too well. I look forward to the new release soon. From teekaysoh at gmail.com Mon Nov 19 12:51:30 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 19 Nov 2007 19:51:30 +0800 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> <0a0d01c82a54$877f1050$967d30f0$@com.au> <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> Message-ID: <58b84f8e0711190351l27b97f07s884c94bbeb803f94@mail.gmail.com> On Nov 19, 2007 7:49 PM, TK Soh wrote: > On Nov 19, 2007 10:31 AM, Mark Hammond wrote: > > Yes - a user running without elevated credentials can't create objects in > > the "Global\\" namespace under Vista - which is exactly what win32trace > > tries to do. This has been fixed in CVS, and I really hope to get a new > > build out within a couple of weeks. IIRC, a workaround is to start a > > "reader" process (ie, "python win32traceutil.py") from a command-prompt > > running elevated (ie, "as Administrator") - a client should then be capable > > of working without requiring elevated permissions, as the mapping will have > > been created and permissions adjusted. > > Thanks for the tip. Though I'm not sure the workaround will work out > too well. I look forward to the new release soon. While we are here, is it possible to add a 'closed' attribute to win32trace also, as I mention in an earlier post to the list? From mhammond at skippinet.com.au Mon Nov 19 12:56:19 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Nov 2007 22:56:19 +1100 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <58b84f8e0711190351l27b97f07s884c94bbeb803f94@mail.gmail.com> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> <0a0d01c82a54$877f1050$967d30f0$@com.au> <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> <58b84f8e0711190351l27b97f07s884c94bbeb803f94@mail.gmail.com> Message-ID: <0a3b01c82aa3$3764fc20$a62ef460$@com.au> > While we are here, is it possible to add a 'closed' attribute to > win32trace also, as I mention in an earlier post to the list? Sure - although I'm afraid your earlier post has been lost (by me). Adding a patch to the pywin32 project at sourceforge is probably the best way to ensure that doesn't happen in the future... Cheers, Mark From teekaysoh at gmail.com Mon Nov 19 13:05:43 2007 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 19 Nov 2007 20:05:43 +0800 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <0a3b01c82aa3$3764fc20$a62ef460$@com.au> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> <0a0d01c82a54$877f1050$967d30f0$@com.au> <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> <58b84f8e0711190351l27b97f07s884c94bbeb803f94@mail.gmail.com> <0a3b01c82aa3$3764fc20$a62ef460$@com.au> Message-ID: <58b84f8e0711190405j7c47ae53o885fb927adf16af5@mail.gmail.com> On Nov 19, 2007 7:56 PM, Mark Hammond wrote: > > While we are here, is it possible to add a 'closed' attribute to > > win32trace also, as I mention in an earlier post to the list? > > Sure - although I'm afraid your earlier post has been lost (by me). > Adding a patch to the pywin32 project at sourceforge is probably the > best way to ensure that doesn't happen in the future... My original post is as below: It looks like the "closed" attribute for sys.stderr and sys.stdout are missing when win32trace is in effect. Any way to work around this? python script: -------------------------- import win32traceutil import sys if not sys.stdout.closed: print "stdout is opened" -------------------------- Trace collector output: -------------------------- Traceback (most recent call last): File "try.py", line 3, in if not sys.stdout.closed: AttributeError: 'PyTraceObject' object has no attribute 'closed' From mhammond at skippinet.com.au Mon Nov 19 13:28:59 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Nov 2007 23:28:59 +1100 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <58b84f8e0711190405j7c47ae53o885fb927adf16af5@mail.gmail.com> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> <0a0d01c82a54$877f1050$967d30f0$@com.au> <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> <58b84f8e0711190351l27b97f07s884c94bbeb803f94@mail.gmail.com> <0a3b01c82aa3$3764fc20$a62ef460$@com.au> <58b84f8e0711190405j7c47ae53o885fb927adf16af5@mail.gmail.com> Message-ID: <0a4a01c82aa7$c74b3940$55e1abc0$@com.au> I'm afraid I can't suggest a work-around (other than the obvious "catch the AttributeError"), but would be happy to look at a patch that adds such an attribute. Mark > -----Original Message----- > From: TK Soh [mailto:teekaysoh at gmail.com] > Sent: Monday, 19 November 2007 11:06 PM > To: Mark Hammond > Cc: Python-Win32 List; Steve Borho > Subject: Re: [python-win32] win32tracutil traceback on Vista > > On Nov 19, 2007 7:56 PM, Mark Hammond > wrote: > > > While we are here, is it possible to add a 'closed' attribute to > > > win32trace also, as I mention in an earlier post to the list? > > > > Sure - although I'm afraid your earlier post has been lost (by me). > > Adding a patch to the pywin32 project at sourceforge is probably the > > best way to ensure that doesn't happen in the future... > > My original post is as below: > > It looks like the "closed" attribute for sys.stderr and sys.stdout are > missing when win32trace is in effect. Any way to work around this? > > python script: > -------------------------- > import win32traceutil > import sys > if not sys.stdout.closed: > print "stdout is opened" > -------------------------- > > Trace collector output: > -------------------------- > Traceback (most recent call last): > File "try.py", line 3, in > if not sys.stdout.closed: > AttributeError: 'PyTraceObject' object has no attribute 'closed' From bgailer at alum.rpi.edu Mon Nov 19 16:49:30 2007 From: bgailer at alum.rpi.edu (bob gailer) Date: Mon, 19 Nov 2007 10:49:30 -0500 Subject: [python-win32] want to leave DOS console at any target dir In-Reply-To: References: Message-ID: <4741B08A.80500@alum.rpi.edu> Charlie wrote: > When launching a python script from a DOS console, > I can not find a way to leave the DOS console at a working directory > other than the initial working directory. > Why do you want to do this? Might there be other approaches? From patrick at gxlinc.com Tue Nov 20 00:15:33 2007 From: patrick at gxlinc.com (Patrick Li) Date: Mon, 19 Nov 2007 15:15:33 -0800 Subject: [python-win32] Detect when the user launches or closes a program? Message-ID: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> Hi, I am trying to write a program that will perform some operation on the user's computer when the user launches a particular executable(s) on the computer and when the user closes them. One way to achieve this is by polling the process table periodically and checking to see if one of the running processes matches the executable name that I am looking for. However, I would much prefer not polling so frequently as it seems to be a waste of user's system resource. Does anyone know if there is a way to hook a callback to windows where it will trigger my function when windows launches a particular program? I think that would be the ideal thing to do if that is available. Thanks. Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071119/8504ea99/attachment.htm From timr at probo.com Tue Nov 20 00:37:16 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 19 Nov 2007 15:37:16 -0800 Subject: [python-win32] Detect when the user launches or closes a program? In-Reply-To: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> References: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> Message-ID: <47421E2C.8050604@probo.com> Patrick Li wrote: > > I am trying to write a program that will perform some operation on the > user's computer when the user launches a particular executable(s) on > the computer and when the user closes them. > > One way to achieve this is by polling the process table periodically > and checking to see if one of the running processes matches the > executable name that I am looking for. However, I would much prefer > not polling so frequently as it seems to be a waste of user's system > resource. > > Does anyone know if there is a way to hook a callback to windows where > it will trigger my function when windows launches a particular > program? I think that would be the ideal thing to do if that is > available. You can implement a system-wide WH_CBT hook, and watch for events like HCBT_ACTIVEATE or HCBT_CREATEWND or HCBT_DESTROYWND. However, remember that a system-wide hook causes your DLL to be injected into every running process, and gets involved with EVERY window message for EVERY process. It's not clear to me that it will have less of an impact on performance than a periodic scan of the process table. Also, you aren't going to be able to write such a hook in Python. A hook procedure lives in a very restricted environment, because you are actually executing inside another process. You can't even reliably allocate memory. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bgailer at alum.rpi.edu Tue Nov 20 00:47:32 2007 From: bgailer at alum.rpi.edu (bob gailer) Date: Mon, 19 Nov 2007 18:47:32 -0500 Subject: [python-win32] Detect when the user launches or closes a program? In-Reply-To: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> References: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> Message-ID: <47422094.3040303@alum.rpi.edu> Patrick Li wrote: > Hi, > > I am trying to write a program that will perform some operation on the > user's computer when the user launches a particular executable(s) on > the computer and when the user closes them. > > One way to achieve this is by polling the process table periodically > and checking to see if one of the running processes matches the > executable name that I am looking for. However, I would much prefer > not polling so frequently as it seems to be a waste of user's system > resource. If you have control over the user's environment give him a .bat file that will perform some operation on his computer and launch the executable. From patrick at gxlinc.com Tue Nov 20 01:13:50 2007 From: patrick at gxlinc.com (Patrick Li) Date: Mon, 19 Nov 2007 16:13:50 -0800 Subject: [python-win32] Detect when the user launches or closes a program? In-Reply-To: <47422094.3040303@alum.rpi.edu> References: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> <47422094.3040303@alum.rpi.edu> Message-ID: <2b5a48740711191613h46931129q1926863617091662@mail.gmail.com> On 11/19/07, bob gailer wrote: > > Patrick Li wrote: > > Hi, > > > > I am trying to write a program that will perform some operation on the > > user's computer when the user launches a particular executable(s) on > > the computer and when the user closes them. > > > > One way to achieve this is by polling the process table periodically > > and checking to see if one of the running processes matches the > > executable name that I am looking for. However, I would much prefer > > not polling so frequently as it seems to be a waste of user's system > > resource. > If you have control over the user's environment give him a .bat file > that will perform some operation on his computer and launch the > executable. Thought about that, too. Unfortunately I'll have no control over the user's environment. All I will know is the name of the executable file as well as the path at which it is located. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071119/bfeee046/attachment-0001.htm From teekaysoh at gmail.com Tue Nov 20 03:21:33 2007 From: teekaysoh at gmail.com (TK Soh) Date: Tue, 20 Nov 2007 02:21:33 +0000 Subject: [python-win32] win32tracutil traceback on Vista In-Reply-To: <0a4a01c82aa7$c74b3940$55e1abc0$@com.au> References: <58b84f8e0711181704l61fe8418t258d081efd5fd740@mail.gmail.com> <0a0d01c82a54$877f1050$967d30f0$@com.au> <58b84f8e0711190349p1954e9q1f9c3d61cbf1ec73@mail.gmail.com> <58b84f8e0711190351l27b97f07s884c94bbeb803f94@mail.gmail.com> <0a3b01c82aa3$3764fc20$a62ef460$@com.au> <58b84f8e0711190405j7c47ae53o885fb927adf16af5@mail.gmail.com> <0a4a01c82aa7$c74b3940$55e1abc0$@com.au> Message-ID: <58b84f8e0711191821v21337aabob6fcf61683c6f2d9@mail.gmail.com> On Nov 19, 2007 12:28 PM, Mark Hammond wrote: > I'm afraid I can't suggest a work-around (other than the obvious "catch the AttributeError"), but would be happy to look at a patch that adds such an attribute. Unfortunately I don't currently meet the minimum requirement to compile pythonwin, since I only have MingW. Hopefully someone else can to workout a patch on this. From mail at timgolden.me.uk Tue Nov 20 10:14:43 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 20 Nov 2007 09:14:43 +0000 Subject: [python-win32] Detect when the user launches or closes a program? In-Reply-To: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> References: <2b5a48740711191515y29ef45b4w1f0a1107f7dcdfc9@mail.gmail.com> Message-ID: <4742A583.9020509@timgolden.me.uk> Patrick Li wrote: > Hi, > > I am trying to write a program that will perform some operation on the > user's computer when the user launches a particular executable(s) on the > computer and when the user closes them. To a limited extent you can do this with WMI. Have a look here for an example: http://timgolden.me.uk/python/wmi_cookbook.html#watch_notepad TJG From cappy2112 at gmail.com Tue Nov 20 21:14:18 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Tue, 20 Nov 2007 12:14:18 -0800 Subject: [python-win32] Detect when the user launches or closes a Message-ID: <8249c4ac0711201214j63bb761ex9468f20442ef9390@mail.gmail.com> Patrick, See if this helps. http://www.mindtrove.info/articles/pyhook.html I think it's somewhat similar to Tim Robert's suggestion, just packaged differently. I haven't tried it myself- so let us know how it works for your situation. Message: 7 Date: Mon, 19 Nov 2007 15:15:33 -0800 From: "Patrick Li" Subject: [python-win32] Detect when the user launches or closes a program? Hi, I am trying to write a program that will perform some operation on the user's computer when the user launches a particular executable(s) on the computer and when the user closes them. From Andrew.MACKEITH at 3ds.com Tue Nov 20 16:05:49 2007 From: Andrew.MACKEITH at 3ds.com (MACKEITH Andrew) Date: Tue, 20 Nov 2007 10:05:49 -0500 Subject: [python-win32] Compiling win32 extensions In-Reply-To: <09ea01c82a2f$98553690$c8ffa3b0$@com.au> References: <098901c82988$63961390$2ac23ab0$@com.au> <09ea01c82a2f$98553690$c8ffa3b0$@com.au> Message-ID: ________________________________ From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Sunday, November 18, 2007 5:09 PM To: MACKEITH Andrew; python-win32 at python.org Subject: RE: [python-win32] Compiling win32 extensions Oops - my mistake! Please see pywintypes.h, where you will find a block: // As of Python 2.6, Python switched to 'wchar_t' for unicode. Some old // win32 structures that still use 'unsigned short' now fail from C++ with // VS8 so we provide a couple of helpers. // XXX - but, when trying to use VC2003 with x64, the SDK x64 compiler // reports itself as 14.00.40310.41 - so this breaks under that compiler // Its not clear how to resolve this, but while VS2003 is the default // compiler, that is what must work. #if 0 // and _MSC_VER >= 1400 ... Sadly, I can't think of anything to test that works in all cases, so you will need to manually enable that block. Any ideas regarding what to test for would be appreciated... Cheers, Mark I did as you suggested, but I can't see what difference this would make to line 1266 of win32apimodule.cpp. I changed line 1266 to //rc = ::GetFileAttributesW(PyUnicode_AS_UNICODE(obPathName)); rc = ::GetFileAttributesW(PyWinObject_FreeWCHAR(obPathName)); but the error is now: win32apimodule.cpp win32/src/win32apimodule.cpp(1267) : error C2665: 'PyWinObject_FreeWCHAR' : none of the 2 overloads could convert all the argument types p:\cae\python\upgrade\6-8\builds\win86_32\win32ext\pywin32\win32\src\PyW inTypes.h(161): could be 'void PyWinObject_FreeWCHAR(WCHAR *)' p:\cae\python\upgrade\6-8\builds\win86_32\win32ext\pywin32\win32\src\PyW inTypes.h(175): or 'void PyWinObject_FreeWCHAR(unsigned short *)' while trying to match the argument list '(PyObject *)' Andrew From: MACKEITH Andrew [mailto:Andrew.MACKEITH at 3ds.com] Sent: Sunday, 18 November 2007 3:01 PM To: Mark Hammond; python-win32 at python.org Subject: RE: [python-win32] Compiling win32 extensions ________________________________ From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Saturday, November 17, 2007 9:12 PM To: MACKEITH Andrew; python-win32 at python.org Subject: RE: [python-win32] Compiling win32 extensions Although VS8 is not officially supported and no official binaries are released built with that version, you should find the CVS version of pywin32 builds cleanly with VS8, even if you target x64. Cheers, Mark I downloaded the CVS tree on Nov 9th, and I am building with that. How does LPCWSTR relate to Py_UNICODE? win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Andrew From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org] On Behalf Of MACKEITH Andrew Sent: Saturday, 10 November 2007 5:58 AM To: python-win32 at python.org Subject: [python-win32] Compiling win32 extensions I am compiling the win32 extensions on 32 bit windows using Microsoft Visual Studio 8 (AKA .Net 2005) I have had some problems with paths, but managed to solve these by manually adding paths to the registry. (I am puzzled that dsound.h appears in the SDK for ce, but not the regular SDK.) I am now stumped by these (related) compile errors. win32apimodule.cpp win32/src/win32apimodule.cpp(1266) : error C2664: 'GetFileAttributesW' : cannot convert parameter 1 from 'Py_UNICODE *' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1451) : error C2664: 'PyUnicodeUCS2_FromUnicode' : cannot convert parameter 1 from 'wchar_t [260]' to 'const Py_UNICODE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast win32/src/win32apimodule.cpp(1975) : error C2664: 'DWORD (LPCWSTR,LPWSTR,DWORD)' : cannot convert parameter 2 from 'Py_UNICODE *' to 'LPWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Are these new errors in Visual Studio 8? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071120/a0d13b24/attachment.htm From pyth_ora at yahoo.com Wed Nov 21 20:13:41 2007 From: pyth_ora at yahoo.com (Jd H) Date: Wed, 21 Nov 2007 11:13:41 -0800 (PST) Subject: [python-win32] Python and Excel via Cron Message-ID: <724132.37101.qm@web57303.mail.re1.yahoo.com> Hello, I have the below python code which opens an excel sheet, runs a macro then save the file. When run from python it runs perfectly. Code is below. File name is test.py <<< from win32com.client import Dispatch myExcel = Dispatch('Excel.Application') myExcel.Visible = 1 myExcel.Workbooks.Add('C:\Python24\test.xls') myExcel.Workbooks.Add('C:\Python24\macro.XLA') myExcel.Run('Macro1') myExcel.Application.DisplayAlerts = False myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') myExcel.Quit() >>> When run from cron, it fails at line 3 when it opens the file with below message: Traceback (most recent call last): File "c:\Python24\test.py", line 20, in ? jd.Workbooks.Add('C:\Python24\test.xls') File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Workbooks Any ideas how to resolve this? Thanks, JD --------------------------------- Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071121/3d1b32ee/attachment.htm From bgailer at alum.rpi.edu Wed Nov 21 20:32:33 2007 From: bgailer at alum.rpi.edu (bob gailer) Date: Wed, 21 Nov 2007 14:32:33 -0500 Subject: [python-win32] Python and Excel via Cron In-Reply-To: <724132.37101.qm@web57303.mail.re1.yahoo.com> References: <724132.37101.qm@web57303.mail.re1.yahoo.com> Message-ID: <474487D1.2040900@alum.rpi.edu> Jd H wrote: > Hello, > > I have the below python code which opens an excel sheet, runs a macro > then save the file. When run from python it runs perfectly. Code is > below. File name is test.py > > <<< > from win32com.client import Dispatch > > myExcel = Dispatch('Excel.Application') > myExcel.Visible = 1 > myExcel.Workbooks.Add('C:\Python24\test.xls') > myExcel.Workbooks.Add('C:\Python24\macro.XLA') > myExcel.Run('Macro1') > myExcel.Application.DisplayAlerts = False > myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') > myExcel.Quit() > >>> > > When run from cron, it fails at line 3 when it opens the file with > below message: > > Traceback (most recent call last): > File "c:\Python24\test.py", line 20, in ? > jd.Workbooks.Add('C:\Python24\test.xls') > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > line 496, in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: Excel.Application.Workbooks cron on Windows??? I did not know Windows had cron! "fails at line 3???" The traceback refers to line 20. Is there another test.py involved?? Let's start there? And post the other version of text.py for us. From timr at probo.com Wed Nov 21 23:03:24 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 21 Nov 2007 14:03:24 -0800 Subject: [python-win32] Python and Excel via Cron In-Reply-To: <724132.37101.qm@web57303.mail.re1.yahoo.com> References: <724132.37101.qm@web57303.mail.re1.yahoo.com> Message-ID: <4744AB2C.5050302@probo.com> Jd H wrote: > Hello, > > I have the below python code which opens an excel sheet, runs a macro > then save the file. When run from python it runs perfectly. Code is > below. File name is test.py > > <<< > from win32com.client import Dispatch > > myExcel = Dispatch('Excel.Application') > myExcel.Visible = 1 > myExcel.Workbooks.Add('C:\Python24\test.xls') I don't believe this ever ran correctly as you have posted it. This will not open a file called "test.xls" in the directory "Python24". Instead, this will open a file in the root called "Python24est.xls" with a tab character in the name. You HAVE to be careful about backslashes in Python. Either double the backslashes, replace them with forward slashes, or use a raw string ( r'c:\Python24\test.xls' ). > myExcel.Workbooks.Add('C:\Python24\macro.XLA') > myExcel.Run('Macro1') > myExcel.Application.DisplayAlerts = False > myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') > myExcel.Quit() > >>> > > When run from cron, it fails at line 3 when it opens the file with > below message: > > Traceback (most recent call last): > File "c:\Python24\test.py", line 20, in ? > jd.Workbooks.Add('C:\Python24\test.xls') > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > line 496, in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: Excel.Application.Workbooks > > Any ideas how to resolve this? What utility are you using to schedule this? Are you actually using Cygwin's cron, or the "at" command, or the standard "Schedule Tasks" thing, or what? What operating system are you using? Most of the task scheduler tools run as a service. By default, a service cannot launch a GUI application. Also, in some cases, the services run as a user that has restricted rights. Tell us a little more about how you are doing this, and perhaps we can suggest how to accomplish it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sjmachin at lexicon.net Wed Nov 21 23:31:10 2007 From: sjmachin at lexicon.net (John Machin) Date: Thu, 22 Nov 2007 09:31:10 +1100 Subject: [python-win32] Python and Excel via Cron In-Reply-To: <724132.37101.qm@web57303.mail.re1.yahoo.com> References: <724132.37101.qm@web57303.mail.re1.yahoo.com> Message-ID: <4744B1AE.7000501@lexicon.net> Jd H wrote: > Hello, > > I have the below python code which opens an excel sheet, runs a macro then save the file. When run from python it runs perfectly. Code is below. File name is test.py > What does "run from python" mean?? > > <<< > What's that "<<<"?? If you meant to type ">>>", don't type, COPY/PASTE!! > from win32com.client import Dispatch > > myExcel = Dispatch('Excel.Application') > myExcel.Visible = 1 > myExcel.Workbooks.Add('C:\Python24\test.xls') > 1. Dunno how that can work without using raw string; '\t' is a TAB character ... 2. Storing data files in a software installation directory is not a good idea. 3. Python 2.4? > myExcel.Workbooks.Add('C:\Python24\macro.XLA') > myExcel.Run('Macro1') > myExcel.Application.DisplayAlerts = False > myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') > myExcel.Quit() > >>> > > When run from cron, it fails at line 3 when it opens the file with below message: > cron on Windows? cygwin? > > Traceback (most recent call last): > File "c:\Python24\test.py", line 20, in ? > jd.Workbooks.Add('C:\Python24\test.xls') > NOT the same code as quoted above (line 3 vs line 20, myExcel vs jd) > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: Excel.Application.Workbooks > > Any ideas how to resolve this? > More info required: what is your environment, what exactly are you doing, exact code that you are trying to execute. From pyth_ora at yahoo.com Thu Nov 22 00:05:08 2007 From: pyth_ora at yahoo.com (Jd H) Date: Wed, 21 Nov 2007 15:05:08 -0800 (PST) Subject: [python-win32] Python and Excel via Cron In-Reply-To: <4744AB2C.5050302@probo.com> Message-ID: <137472.82358.qm@web57314.mail.re1.yahoo.com> I am posting test.py again below: <<< from win32com.client import Dispatch myExcel = Dispatch('Excel.Application') myExcel.Workbooks.Add('C:\Python24\\test.xls') myExcel.Workbooks.Add('C:\Python24\\macro.XLA') myExcel.Run('Macro1') myExcel.Application.DisplayAlerts = False myExcel.ActiveWorkbook.SaveAs('C:\Python24\\test.xls') myExcel.Quit() >>> Cygwin cron calling test.py works great on my Windows XP PC with Python 2.4 version. From windows 2000 terminal server with same Python 2.4 version, it works perfectly as it is supposed to if run via Python 2.4. But if called via cygwin cron (like it needs to be), it fails per below error: Traceback (most recent call last): File "c:\Python24\test.py", line 4, in ? myExcel.Workbooks.Add('C:\Python24\\test.xls') File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Workbooks Thanks, JD Tim Roberts wrote: Jd H wrote: > Hello, > > I have the below python code which opens an excel sheet, runs a macro > then save the file. When run from python it runs perfectly. Code is > below. File name is test.py > > <<< > from win32com.client import Dispatch > > myExcel = Dispatch('Excel.Application') > myExcel.Visible = 1 > myExcel.Workbooks.Add('C:\Python24\test.xls') I don't believe this ever ran correctly as you have posted it. This will not open a file called "test.xls" in the directory "Python24". Instead, this will open a file in the root called "Python24est.xls" with a tab character in the name. You HAVE to be careful about backslashes in Python. Either double the backslashes, replace them with forward slashes, or use a raw string ( r'c:\Python24\test.xls' ). > myExcel.Workbooks.Add('C:\Python24\macro.XLA') > myExcel.Run('Macro1') > myExcel.Application.DisplayAlerts = False > myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') > myExcel.Quit() > >>> > > When run from cron, it fails at line 3 when it opens the file with > below message: > > Traceback (most recent call last): > File "c:\Python24\test.py", line 20, in ? > jd.Workbooks.Add('C:\Python24\test.xls') > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > line 496, in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: Excel.Application.Workbooks > > Any ideas how to resolve this? What utility are you using to schedule this? Are you actually using Cygwin's cron, or the "at" command, or the standard "Schedule Tasks" thing, or what? What operating system are you using? Most of the task scheduler tools run as a service. By default, a service cannot launch a GUI application. Also, in some cases, the services run as a user that has restricted rights. Tell us a little more about how you are doing this, and perhaps we can suggest how to accomplish it. -- 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 --------------------------------- Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071121/e5c469aa/attachment.htm From timr at probo.com Thu Nov 22 00:24:56 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 21 Nov 2007 15:24:56 -0800 Subject: [python-win32] Python and Excel via Cron In-Reply-To: <137472.82358.qm@web57314.mail.re1.yahoo.com> References: <137472.82358.qm@web57314.mail.re1.yahoo.com> Message-ID: <4744BE48.5060209@probo.com> Jd H wrote: > I am posting test.py again below: > > <<< > from win32com.client import Dispatch > > myExcel = Dispatch('Excel.Application') > myExcel.Workbooks.Add('C:\Python24\\test.xls') > myExcel.Workbooks.Add('C:\Python24\\macro.XLA') That's still not right. It will work this time, until some Python upgrade where \p becomes a valid escape sequence. Seriously, any time you write a path in Python in Windows, you need to either: * Double ALL of the backslashes * Use forward slashes, or * Use raw strings Make it habit, every time, and you will avoid bugs. > myExcel.Run('Macro1') > myExcel.Application.DisplayAlerts = False > myExcel.ActiveWorkbook.SaveAs('C:\Python24\\test.xls') > myExcel.Quit() > >>> > > Cygwin cron calling test.py works great on my Windows XP PC with > Python 2.4 version. From windows 2000 terminal server with same Python > 2.4 version, it works perfectly as it is supposed to if run via Python > 2.4. But if called via cygwin cron (like it needs to be), it fails per > below error: > ... > AttributeError: Excel.Application.Workbooks Are you starting cron in your Terminal Server session and then disconnecting, hoping that it keeps running? Or are you launching cron from the server's console? A disconnected Terminal Server session doesn't have a desktop. GUI applications can't run without a desktop. Also Terminal Server has a lot of complicated security options; is your username allowed to run applications at the console? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From larry.bates at websafe.com Thu Nov 22 00:28:05 2007 From: larry.bates at websafe.com (Larry Bates) Date: Wed, 21 Nov 2007 17:28:05 -0600 Subject: [python-win32] Python and Excel via Cron In-Reply-To: <137472.82358.qm@web57314.mail.re1.yahoo.com> References: <4744AB2C.5050302@probo.com> <137472.82358.qm@web57314.mail.re1.yahoo.com> Message-ID: Why are you using Cygwin cron instead of native Windows Task Scheduler (Windows version of cron-like scheduler)? These lines: > myExcel.Workbooks.Add('C:\Python24\\test.xls') > myExcel.Workbooks.Add('C:\Python24\\macro.XLA') > myExcel.ActiveWorkbook.SaveAs('C:\Python24\\test.xls') should read: > myExcel.Workbooks.Add('C:\\Python24\\test.xls') > myExcel.Workbooks.Add('C:\\Python24\\macro.XLA') > myExcel.ActiveWorkbook.SaveAs('C:\\Python24\\test.xls') -Larry Jd H wrote: > I am posting test.py again below: > > <<< > from win32com.client import Dispatch > > myExcel = Dispatch('Excel.Application') > myExcel.Workbooks.Add('C:\Python24\\test.xls') > myExcel.Workbooks.Add('C:\Python24\\macro.XLA') > myExcel.Run('Macro1') > myExcel.Application.DisplayAlerts = False > myExcel.ActiveWorkbook.SaveAs('C:\Python24\\test.xls') > myExcel.Quit() > >>> > > Cygwin cron calling test.py works great on my Windows XP PC with Python > 2.4 version. From windows 2000 terminal server with same Python 2.4 > version, it works perfectly as it is supposed to if run via Python 2.4. > But if called via cygwin cron (like it needs to be), it fails per below > error: > > Traceback (most recent call last): > File "c:\Python24\test.py", line 4, in ? > myExcel.Workbooks.Add('C:\Python24\\test.xls') > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line > 496, in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: Excel.Application.Workbooks > Thanks, > JD > > */Tim Roberts /* wrote: > > Jd H wrote: > > Hello, > > > > I have the below python code which opens an excel sheet, runs a macro > > then save the file. When run from python it runs perfectly. Code is > > below. File name is test.py > > > > <<< > > from win32com.client import Dispatch > > ; > > myExcel = Dispatch('Excel.Application') > > myExcel.Visible = 1 > > myExcel.Workbooks.Add('C:\Python24\test.xls') > > I don't believe this ever ran correctly as you have posted it. This > will not open a file called "test.xls" in the directory "Python24". > Instead, this will open a file in the root called "Python24est.xls" > with a tab character in the name. You HAVE to be careful about > backslashes in Python. Either double the backslashes, replace them with > forward slashes, or use a raw string ( r'c:\Python24\test.xls' ). > > > myExcel.Workbooks.Add('C:\Python24\macro.XLA') > > myExcel.Run('Macro1') > > myExcel.Application.DisplayAlerts = False > > myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') > > myExcel.Quit() > > >>> > > > > When run from cron, it fails at line 3 when it opens the file with > > below message: > > > > Traceback (most recent call last): > > File "c :\Python24\test.py", line 20, in ? > > jd.Workbooks.Add('C:\Python24\test.xls') > > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > > line 496, in __getattr__ > > raise AttributeError, "%s.%s" % (self._username_, attr) > > AttributeError: Excel.Application.Workbooks > > > > Any ideas how to resolve this? > > What utility are you using to schedule this? Are you actually using > Cygwin's cron, or the "at" command, or the standard "Schedule Tasks" > thing, or what? What operating system are you using? > > Most of the task scheduler tools run as a service. By default, a > service cannot launch a GUI application. Also, in some cases, the > services run as a user that has restricted rights. Tell us a little > more about how you are doing this, and perhaps we can suggest how to > accomplish it. > > -- > 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 > > > ------------------------------------------------------------------------ > Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try > it now. > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From pyth_ora at yahoo.com Thu Nov 22 00:40:25 2007 From: pyth_ora at yahoo.com (Jd H) Date: Wed, 21 Nov 2007 15:40:25 -0800 (PST) Subject: [python-win32] Python and Excel via Cron In-Reply-To: Message-ID: <35267.91619.qm@web57313.mail.re1.yahoo.com> I included an additional backslash and still same error type below: Traceback (most recent call last): File "c:\Python24\test.py", line 4, in ? myExcel.Workbooks.Add('C:\\Python24\\test.xls') File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Workbooks I have other processes running on a daily/ minute basis and they run via cron. So I don't think it is a permission issue. Excel is running (several instances for each failure). --- Larry Bates wrote: > Why are you using Cygwin cron instead of native > Windows Task Scheduler (Windows > version of cron-like scheduler)? > > These lines: > > > myExcel.Workbooks.Add('C:\Python24\\test.xls') > > myExcel.Workbooks.Add('C:\Python24\\macro.XLA') > > > > myExcel.ActiveWorkbook.SaveAs('C:\Python24\\test.xls') > > should read: > > > myExcel.Workbooks.Add('C:\\Python24\\test.xls') > > myExcel.Workbooks.Add('C:\\Python24\\macro.XLA') > > > > myExcel.ActiveWorkbook.SaveAs('C:\\Python24\\test.xls') > > -Larry > > > Jd H wrote: > > I am posting test.py again below: > > > > <<< > > from win32com.client import Dispatch > > > > myExcel = Dispatch('Excel.Application') > > myExcel.Workbooks.Add('C:\Python24\\test.xls') > > myExcel.Workbooks.Add('C:\Python24\\macro.XLA') > > myExcel.Run('Macro1') > > myExcel.Application.DisplayAlerts = False > > > myExcel.ActiveWorkbook.SaveAs('C:\Python24\\test.xls') > > myExcel.Quit() > > >>> > > > > Cygwin cron calling test.py works great on my > Windows XP PC with Python > > 2.4 version. From windows 2000 terminal server > with same Python 2.4 > > version, it works perfectly as it is supposed to > if run via Python 2.4. > > But if called via cygwin cron (like it needs to > be), it fails per below > > error: > > > > Traceback (most recent call last): > > File "c:\Python24\test.py", line 4, in ? > > myExcel.Workbooks.Add('C:\Python24\\test.xls') > > File > "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > line > > 496, in __getattr__ > > raise AttributeError, "%s.%s" % > (self._username_, attr) > > AttributeError: Excel.Application.Workbooks > > Thanks, > > JD > > > > */Tim Roberts /* wrote: > > > > Jd H wrote: > > > Hello, > > > > > > I have the below python code which opens an > excel sheet, runs a macro > > > then save the file. When run from python it > runs perfectly. Code is > > > below. File name is test.py > > > > > > <<< > > > from win32com.client import Dispatch > > > ; > > > myExcel = Dispatch('Excel.Application') > > > myExcel.Visible = 1 > > > > myExcel.Workbooks.Add('C:\Python24\test.xls') > > > > I don't believe this ever ran correctly as you > have posted it. This > > will not open a file called "test.xls" in the > directory "Python24". > > Instead, this will open a file in the root > called "Python24est.xls" > > with a tab character in the name. You HAVE to > be careful about > > backslashes in Python. Either double the > backslashes, replace them with > > forward slashes, or use a raw string ( > r'c:\Python24\test.xls' ). > > > > > > myExcel.Workbooks.Add('C:\Python24\macro.XLA') > > > myExcel.Run('Macro1') > > > myExcel.Application.DisplayAlerts = False > > > > myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls') > > > myExcel.Quit() > > > >>> > > > > > > When run from cron, it fails at line 3 when > it opens the file with > > > below message: > > > > > > Traceback (most recent call last): > > > File "c :\Python24\test.py", line 20, in ? > > > jd.Workbooks.Add('C:\Python24\test.xls') > > > File > "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > > > line 496, in __getattr__ > > > raise AttributeError, "%s.%s" % > (self._username_, attr) > > > AttributeError: Excel.Application.Workbooks > > > > > > Any ideas how to resolve this? > > > > What utility are you using to schedule this? > Are you actually using > > Cygwin's cron, or the "at" command, or the > standard "Schedule Tasks" > > thing, or what? What operating system are you > using? > > > > Most of the task scheduler tools run as a > service. By default, a > > service cannot launch a GUI application. Also, > in some cases, the > > services run as a user that has restricted > rights. Tell us a little > > more about how you are doing this, and perhaps > we can suggest how to > > accomplish it. > > > > -- > > 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 > > > > > > > ------------------------------------------------------------------------ > > Be a better sports nut! Let your teams follow you > with Yahoo Mobile. Try > > it now. > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > 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 > ____________________________________________________________________________________ Get easy, one-click access to your favorites. Make Yahoo! your homepage. http://www.yahoo.com/r/hs From charlie at sallyandcharlie.com Thu Nov 22 07:16:49 2007 From: charlie at sallyandcharlie.com (Charlie) Date: Thu, 22 Nov 2007 06:16:49 +0000 (UTC) Subject: [python-win32] want to leave DOS console at any target dir References: <4741B08A.80500@alum.rpi.edu> Message-ID: bob gailer alum.rpi.edu> writes: > > Charlie wrote: > > When launching a python script from a DOS console, > > I can not find a way to leave the DOS console at a working directory > > other than the initial working directory. > > > Why do you want to do this? Might there be other approaches? > No, the whole idea is to provide myself a convenience function to leave me at the right subdirectory based on my python scripts results. It's not really necessary, it just saves me a manual "CD" after the script terminates. From mc at mclaveau.com Thu Nov 22 08:34:55 2007 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 22 Nov 2007 08:34:55 +0100 Subject: [python-win32] want to leave DOS console at any target dir In-Reply-To: References: Message-ID: Hi! Try this: import os os.system('start "TITLE" "cmd /KCD /DD:\\Dev\\python"') #for dir: D:\\Dev\\python ("TITLE" is the title (yes!) of the window) @-salutations Michel Claveau From charlie at sallyandcharlie.com Thu Nov 22 10:57:26 2007 From: charlie at sallyandcharlie.com (Charlie) Date: Thu, 22 Nov 2007 09:57:26 +0000 (UTC) Subject: [python-win32] want to leave DOS console at any target dir References: Message-ID: Michel Claveau mclaveau.com> writes: > > Hi! > > Try this: > import os > os.system('start "TITLE" "cmd /KCD /DD:\\Dev\\python"') #for dir: > D:\\Dev\\python > > ("TITLE" is the title (yes!) of the window) > > @-salutations > > Michel Claveau > Thanks, That launches a new DOS console at the desired directory location. Pretty close to what I was hoping for. Charlie From p.f.moore at gmail.com Thu Nov 22 14:05:06 2007 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 22 Nov 2007 13:05:06 +0000 Subject: [python-win32] want to leave DOS console at any target dir In-Reply-To: References: Message-ID: <79990c6b0711220505q4ef87301tcb8695bfe97c54e4@mail.gmail.com> On 22/11/2007, Charlie wrote: > That launches a new DOS console at the desired directory location. > > Pretty close to what I was hoping for. You can't really get much closer. A child process (which is what your Python program is) cannot alter the environment (env variables, current directory, wtc) of its parent process (the CMD shell which started the Python program). [There may be extremely hacky low-level ways round this, but it's true is essence]. Unlike Python, batch files can do this, as they are run by the CMD shell itself, rather than as a subprocess. In effect, they have special abilities not available to normal programs. Paul. PS You can do something similar by using a BAT file to run a Python program which prints a CD command that the BAT file reads and executes, but that comes under my definition of "hacky" :-) From patrick at gxlinc.com Thu Nov 29 03:13:51 2007 From: patrick at gxlinc.com (Patrick Li) Date: Wed, 28 Nov 2007 18:13:51 -0800 Subject: [python-win32] setting my windows service as automatic instead of manual Message-ID: <2b5a48740711281813s210bdc42t4bb9b9b341835d30@mail.gmail.com> Hi, I have created a simple windows service using win32serviceutil. I was able to use py2exe to turn it into a windows executable successfully. However, I cannot figure out how I can get the startup type of this service to "automatic" instead of "manual". I understand that I can go through the control panel to do this manually, but I'd like the service to be shipped with the automatic start up type instead of manual. Does anyone know how I can do that? Thanks, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071128/17b5f928/attachment.htm From timr at probo.com Thu Nov 29 19:35:15 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 29 Nov 2007 10:35:15 -0800 Subject: [python-win32] setting my windows service as automatic instead of manual In-Reply-To: <2b5a48740711281813s210bdc42t4bb9b9b341835d30@mail.gmail.com> References: <2b5a48740711281813s210bdc42t4bb9b9b341835d30@mail.gmail.com> Message-ID: <474F0663.4050400@probo.com> Patrick Li wrote: > Hi, > > I have created a simple windows service using win32serviceutil. I was > able to use py2exe to turn it into a windows executable successfully. > However, I cannot figure out how I can get the startup type of this > service to "automatic" instead of "manual". I understand that I can > go through the control panel to do this manually, but I'd like the > service to be shipped with the automatic start up type instead of manual. > > Does anyone know how I can do that? Pass --startup=auto on the command line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From carl at personnelware.com Fri Nov 30 05:59:13 2007 From: carl at personnelware.com (Carl Karsten) Date: Thu, 29 Nov 2007 22:59:13 -0600 Subject: [python-win32] SendMessageTimeout() ? In-Reply-To: <117e01c7d0b5$f6d17a90$090a0a0a@enfoldsystems.local> References: <117e01c7d0b5$f6d17a90$090a0a0a@enfoldsystems.local> Message-ID: <474F98A1.2030006@personnelware.com> Mark Hammond wrote: > Tim writes: > >>> and just in case I haven't hijacked my own thread enough: >>> does >>> pywin32-210.win32-py2.5.exe >>> have any command line switches so I don't have to hit 'next >> next...'? >> I believe it is a standard MSI installer, and if so you should be able >> to use the normal switches. /q and /qn suppress the UI altogether. >> /qb- should display a basic UI but with no modal dialog >> boxes. You may >> need to experiment. > > Actually, the .exe installers are not MSI at all, and sadly they do not > support cmdline options. I'm playing with creating MSI packages, at least > for the x64 build but the 32bit versions probably will not see .msi for a > little while (I see no real advantage, and some costs, in making each build > available as *both* .exe and .msi) Done anything with this? No biggie if you haven't, I just ran into it again and forgot that it wasn't supported. was about to ask about it, and started to slowly remember this thread :) Carl K