From timr at probo.com Mon Jul 2 21:05:40 2012 From: timr at probo.com (Tim Roberts) Date: Mon, 2 Jul 2012 12:05:40 -0700 Subject: [python-win32] Python implementations on Windows 8rt In-Reply-To: References: <4FE1FC2E.1030608@probo.com> <4FE8A662.1010502@probo.com> Message-ID: <4FF1F104.6040408@probo.com> Marcell Vazquez-Chanlatte wrote: > So I've been trying to compile the ARM build for internal testing (aka > have access to the win32 API) WHAT are you trying to compile? You cannot run Win32 applications on Windows RT. CPython (and hence PyWin32) will never run on the ARM version of Windows. Game over. > I'm having trouble actually setting up the project to accept the new > platform. I'm new to visual studio but does anyone have any suggestions? > > Getting : fatal error LNK1112: module machine type 'ARM' conflicts > with target machine type 'X86' Visual Studio 2012 is required for doing Windows RT code. Are you using VS2012? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From prashantpadaganur at gmail.com Tue Jul 3 13:23:04 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Tue, 3 Jul 2012 16:53:04 +0530 Subject: [python-win32] How to find the current/last system state from Python Message-ID: I want to write an application that puts the system in to different sleep states. Like S0,S1...S4. Before changing from one state to another I want to know the current/previous sleep state. For Ex: If the current state is S0 then I want to put it to S1. Or if the previous state was S3 then I want to put the system to S4. I want to know how can I get this state info from python using Win32 apis. The related struct I found on MSDN is SYSTEM_POWER_STATE http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx Any help would be greatly appreciated!!!! -- Br, Prashant G.P -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 3 13:30:16 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 03 Jul 2012 12:30:16 +0100 Subject: [python-win32] How to find the current/last system state from Python In-Reply-To: References: Message-ID: <4FF2D7C8.4070903@timgolden.me.uk> On 03/07/2012 12:23, prashant padaganur wrote: > > I want to write an application that puts the system in to different > sleep states. Like S0,S1...S4. > > Before changing from one state to another I want to know the > current/previous sleep state. > > For Ex: If the current state is S0 then I want to put it to S1. Or if > the previous state was S3 then I want to put the system to S4. > > I want to know how can I get this state info from python using Win32 > apis. The related struct I found on MSDN is SYSTEM_POWER_STATE > > http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx Chances are that WMI can do it: try Googling for "WMI power management" or something similar TJG From prashantpadaganur at gmail.com Wed Jul 4 07:01:06 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Wed, 4 Jul 2012 10:31:06 +0530 Subject: [python-win32] How to find the current/last system state from Python Message-ID: On 03/07/2012 12:23, prashant padaganur wrote: >>* *>>* I want to write an application that puts the system in to different*>>* sleep states. Like S0,S1...S4.*>>* *>>* Before changing from one state to another I want to know the*>>* current/previous sleep state. *>>* *>>* For Ex: If the current state is S0 then I want to put it to S1. Or if*>>* the previous state was S3 then I want to put the system to S4.*>>* *>>* I want to know how can I get this state info from python using Win32*>>* apis. The related struct I found on MSDN is SYSTEM_POWER_STATE *>>* *>>* http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx*> >Chances are that WMI can do it: try Googling for "WMI power management" >or something similar > >TJG No luck so far. If anyone has done something similar please share your thoughts. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Jul 4 09:24:22 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 04 Jul 2012 08:24:22 +0100 Subject: [python-win32] How to find the current/last system state from Python In-Reply-To: References: Message-ID: <4FF3EFA6.1010608@timgolden.me.uk> On 04/07/2012 06:01, prashant padaganur wrote: > On 03/07/2012 12:23, prashant padaganur wrote: >>>/ > />>/ I want to write an application that puts the system in to different > />>/ sleep states. Like S0,S1...S4. > />>/ > />>/ Before changing from one state to another I want to know the > />>/ current/previous sleep state. > />>/ > />>/ For Ex: If the current state is S0 then I want to put it to S1. Or if > />>/ the previous state was S3 then I want to put the system to S4. > />>/ > />>/ I want to know how can I get this state info from python using Win32 > />>/ apis. The related struct I found on MSDN is SYSTEM_POWER_STATE > />>/ > />>/ http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx > /> >>Chances are that WMI can do it: try Googling for "WMI power management" >>or something similar >> >>TJG > > No luck so far. If anyone has done something similar please share your thoughts. Well I haven't, but I Googled for "WMi power management", found this as the 3rd hit: http://www.vbsedit.com/scripts/desktop/info/scr_233.asp which led me to look at this page in MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394102%28v=vs.85%29.aspx and the PowerState attribute: """ PowerState Data type: uint16 Access type: Read-only Current power state of a computer and its associated operating system. The power saving states have the following values: Value 4 (Unknown) indicates that the system is known to be in a power save mode, but its exact status in this mode is unknown; 2 (Low Power Mode) indicates that the system is in a power save state, but still functioning and may exhibit degraded performance; 3 (Standby) indicates that the system is not functioning, but could be brought to full power quickly; and 7 (Warning) indicates that the computer system is in a warning state and a power save mode. This property is inherited from CIM_UnitaryComputerSystem. Value Meaning 0 (0x0) Unknown 1 (0x1) Full Power 2 (0x2) Power Save - Low Power Mode 3 (0x3) Power Save - Standby 4 (0x4) Power Save - Unknown 5 (0x5) Power Cycle 6 (0x6) Power Off 7 (0x7) Power Save - Warning """ which looks to me very similar to the SYSTEM_POWER_STATE struct you referenced from MSDN. Can you say whether this is what you're looking for? import wmi c = wmi.WMI() for sys in c.Win32_ComputerSystem(): print sys.PowerState TJG From prashantpadaganur at gmail.com Wed Jul 4 12:20:57 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Wed, 4 Jul 2012 15:50:57 +0530 Subject: [python-win32] python-win32 Digest, Vol 112, Issue 3 In-Reply-To: References: Message-ID: > > Date: Wed, 04 Jul 2012 08:24:22 +0100 > From: Tim Golden > On 04/07/2012 06:01, prashant padaganur wrote: > > On 03/07/2012 12:23, prashant padaganur wrote: > >>>/ > > />>/ I want to write an application that puts the system in to different > > />>/ sleep states. Like S0,S1...S4. > > />>/ > > />>/ Before changing from one state to another I want to know the > > />>/ current/previous sleep state. > > />>/ > > />>/ For Ex: If the current state is S0 then I want to put it to S1. Or > if > > />>/ the previous state was S3 then I want to put the system to S4. > > />>/ > > />>/ I want to know how can I get this state info from python using Win32 > > />>/ apis. The related struct I found on MSDN is SYSTEM_POWER_STATE > > />>/ > > />>/ > http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx > > /> > >>Chances are that WMI can do it: try Googling for "WMI power management" > >>or something similar > >> > >>TJG > > > > No luck so far. If anyone has done something similar please share your > thoughts. > > > Well I haven't, but I Googled for "WMi power management", found this as > the 3rd hit: > > http://www.vbsedit.com/scripts/desktop/info/scr_233.asp > > > which led me to look at this page in MSDN: > > > > http://msdn.microsoft.com/en-us/library/windows/desktop/aa394102%28v=vs.85%29.aspx > > > and the PowerState attribute: > > > """ > PowerState > > Data type: uint16 > Access type: Read-only > > Current power state of a computer and its associated operating > system. The power saving states have the following values: Value 4 > (Unknown) indicates that the system is known to be in a power save mode, > but its exact status in this mode is unknown; 2 (Low Power Mode) > indicates that the system is in a power save state, but still > functioning and may exhibit degraded performance; 3 (Standby) indicates > that the system is not functioning, but could be brought to full power > quickly; and 7 (Warning) indicates that the computer system is in a > warning state and a power save mode. This property is inherited from > CIM_UnitaryComputerSystem. > > Value Meaning > > 0 (0x0) > Unknown > > 1 (0x1) > Full Power > > 2 (0x2) > Power Save - Low Power Mode > > 3 (0x3) > Power Save - Standby > > 4 (0x4) > Power Save - Unknown > > 5 (0x5) > Power Cycle > > 6 (0x6) > Power Off > > 7 (0x7) > Power Save - Warning > """ > > which looks to me very similar to the SYSTEM_POWER_STATE struct you > referenced from MSDN. Can you say whether this is what you're looking for? > > > import wmi > > c = wmi.WMI() > for sys in c.Win32_ComputerSystem(): > print sys.PowerState > > > > TJG > ------------------------------ > Tim this might be something similar, but what I am looking for is sleep state. I want the exact api which exposes/returns the SYSTEM_POWER_STATE enum either thru win32ap or wmi. Thank for the help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ferdinandsousa at gmail.com Wed Jul 4 20:21:23 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Wed, 4 Jul 2012 23:51:23 +0530 Subject: [python-win32] Take Screenshot when you log in remotely [Win 7 Pro] Message-ID: Hi List, I use pywin32-217.win-amd64 for Python 2.7 on Windows 7 Professional. I have written a script that uses the screenshot() function from the ImageGrab module of the Python Imaging library and I would like to run this script as a scheduled task. Now for the issues. In the task scheduler, if I select 'Run whether user is logged on or not', it does run, but the scheduler shows it as failed to run. This happens both when logged in or if logged in and session is locked So, I chose to use the 'Run only when user is logged on' option. Now, this works well, when logged on as well as if the session is locked. The problem is if I try to login remotely via RDP this stops working the moment I disconnect. In detail: I log in locally - it works I lock the session - still works I log in remotely to the same session (using mstsc /admin) - still works Now if I disconnect, or even if I minimize my remote session window, it fails. Also, if I log off locally and then try logging in remotely using RDP it works as long as I keep the remote session window open. If I disconnect or even minimize the RDP window, it stops working. Is there any option I could use to make it work under 'Run whether user is logged on or not' Task scheduler option? Maybe I could reduce the privilege level needed to execute python.exe? Any other option to make it run under the 'Run only when user is logged on' option? So that I can log in remotely and then disconnect and have it still work? My problem is I am using selenium webdriver to open a webpage and take a screenshot of it, though in this testing script I am just grabbing whatever is on screen at the point the script is run. Also will Firefox run if a user is not logged in? Code: ##--------------------------------------------------------------------- from ImageGrab import grab as screenshot from time import sleep sleep(2) # delay 2 seconds home_folder = 'C:/Users/ferdinand/Desktop/pics/' def grab_screen(file_path): pic = screenshot() pic.save('%s' % file_path) del pic import datetime d = datetime.datetime.now() filename = 'pic_%d.%02d_.png' % (d.hour,d.minute) LOG = '\n\n##-------------------------\nNew Instance\n' try: grab_screen(home_folder + filename) except Exception,e: LOG += e else: LOG += 'Created file %s' % filename f = open(home_folder + 'log.txt', 'a') f.write(LOG) f.close() ##--------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Jul 5 19:21:17 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 5 Jul 2012 10:21:17 -0700 Subject: [python-win32] How to find the current/last system state from Python In-Reply-To: References: Message-ID: <4FF5CD0D.3040405@probo.com> prashant padaganur wrote: > > Tim this might be something similar, but what I am looking for is > sleep state. I want the exact api which exposes/returns the > SYSTEM_POWER_STATE enum either thru win32ap or wmi. It's a little difficult to figure out what you want. When the system goes into a sleep state, user mode applications stop running. If you are writing a command to change the current power state, then you may safely assume that the system is in S0. Otherwise, your command could not have been started. There are only two possible transitions: from working (S0) to a sleeping state (S1-S5), and from a sleeping state to working (S0). The operating system will not go from standby directly to hibernate; it has to make an intermediate stop in S0. http://www.osronline.com/ddkx/kmarch/pwrmgmt_919j.htm -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Jul 5 19:24:51 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 5 Jul 2012 10:24:51 -0700 Subject: [python-win32] Take Screenshot when you log in remotely [Win 7 Pro] In-Reply-To: References: Message-ID: <4FF5CDE3.60809@probo.com> Ferdinand Sousa wrote: > > I have written a script that uses the screenshot() function from the > ImageGrab module of the Python Imaging library and I would like to run > this script as a scheduled task. > > Now for the issues. In the task scheduler, if I select 'Run whether > user is logged on or not', it does run, but the scheduler shows it as > failed to run. This happens both when logged in or if logged in and > session is locked > > So, I chose to use the 'Run only when user is logged on' option. Now, > this works well, when logged on as well as if the session is locked. > The problem is if I try to login remotely via RDP this stops working > the moment I disconnect. Right. When you disconnect the session, there no longer is any screen to take a shot of. Screenshots are implemented by calling the graphics driver. A disconnected session does not have a graphics driver. Windows does not keep a backing store copy of a session's frame buffer anywhere. When a disconnected session is reconnected, all of the applications are sent "paint" messages to force the screen to be repainted from scratch. > Is there any option I could use to make it work under 'Run whether > user is logged on or not' Task scheduler option? > Maybe I could reduce the privilege level needed to execute python.exe? That won't help. What you ask is simply not possible. The bits you want to grab do not exist. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rupole at hotmail.com Thu Jul 5 20:16:36 2012 From: rupole at hotmail.com (Roger Upole) Date: Thu, 5 Jul 2012 14:16:36 -0400 Subject: [python-win32] How to find the current/last system state from Python References: Message-ID: "prashant padaganur" wrote in message news:CAFypNu8RuhnRAQXWu5GtFZkuje1Dj-=CNrUN7AN+UuhJvdopGA at mail.gmail.com... >I want to write an application that puts the system in to different sleep > states. Like S0,S1...S4. > > Before changing from one state to another I want to know the > current/previous sleep state. > > For Ex: If the current state is S0 then I want to put it to S1. Or if the > previous state was S3 then I want to put the system to S4. > > I want to know how can I get this state info from python using Win32 apis. > The related struct I found on MSDN is SYSTEM_POWER_STATE > > http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx > Any help would be greatly appreciated!!!! > -- > Br, > Prashant G.P > You can probably get the last sleep state by scanning the event log for power events. Roger From rupole at hotmail.com Thu Jul 5 20:16:05 2012 From: rupole at hotmail.com (Roger Upole) Date: Thu, 5 Jul 2012 14:16:05 -0400 Subject: [python-win32] How to find the current/last system state from Python References: Message-ID: "prashant padaganur" wrote in message news:CAFypNu8RuhnRAQXWu5GtFZkuje1Dj-=CNrUN7AN+UuhJvdopGA at mail.gmail.com... >I want to write an application that puts the system in to different sleep > states. Like S0,S1...S4. > > Before changing from one state to another I want to know the > current/previous sleep state. > > For Ex: If the current state is S0 then I want to put it to S1. Or if the > previous state was S3 then I want to put the system to S4. > > I want to know how can I get this state info from python using Win32 apis. > The related struct I found on MSDN is SYSTEM_POWER_STATE > > http://msdn.microsoft.com/en-us/library/windows/desktop/aa373227(v=vs.85).aspx > Any help would be greatly appreciated!!!! > -- > Br, > Prashant G.P > You can probably get the last sleep state by scanning the event log for power events. Roger From prashantpadaganur at gmail.com Fri Jul 6 13:30:32 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Fri, 6 Jul 2012 17:00:32 +0530 Subject: [python-win32] How to find the current/last system state from Python Message-ID: >>prashant padaganur wrote: >>**>>* Tim this might be something similar, but what I am looking for is*>>* sleep state. I want the exact api which exposes/returns the*>>* SYSTEM_POWER_STATE enum either thru win32ap or wmi.* >It's a little difficult to figure out what you want. When the system >goes into a sleep state, user mode applications stop running. If you >are writing a command to change the current power state, then you may >safely assume that the system is in S0. Otherwise, your command could >not have been started. >There are only two possible transitions: from working (S0) to a >sleeping state (S1-S5), and from a sleeping state to working (S0). The >operating system will not go from standby directly to hibernate; it has >to make an intermediate stop in S0. >http://www.osronline.com/ddkx/kmarch/pwrmgmt_919j.htm Thanks Tim. But when the system is in S0 state I want to read that information from the system. May be as suggested I can try getting the previous states from Windows event logger. -------------- next part -------------- An HTML attachment was scrubbed... URL: From prashantpadaganur at gmail.com Fri Jul 6 14:54:31 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Fri, 6 Jul 2012 18:24:31 +0530 Subject: [python-win32] How to disable Windows Firewall using WMI Message-ID: Hi, I am trying to disable the Windows Firewall using WMI. Below is the code. When I am running the VBscript I am not getting any errors. But my python script is coming out with some COM errors. (pasted below) Am I doing something wrong? Here is the code. import wmi,os c = wmi.WMI("WinMgmts:\root\Microsoft\HomeNet") for obj in c.HNet_ConnectionProperties(): print obj print obj.IsFirewalled obj.IsFirewalled = 'False' obj.Put_() #Equivalent VB code ''' Set WMI = GetObject("WinMgmts:\root\Microsoft\HomeNet") Set Objs = WMI.InstancesOf("HNet_ConnectionProperties") For Each Obj In Objs Obj.IsFirewalled = False Obj.Put_ Next ''' ---------- Errors: ---------- Traceback (most recent call last): File "C:/Users/ppadagax/Documents/Scripts/firewall.py", line 3, in c = wmi.WMI("WinMgmts:\root\Microsoft\HomeNet") File "C:\Python27\lib\site-packages\wmi.py", line 1290, in connect handle_com_error () File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error raise klass (com_error=err) x_wmi: -- Cheers, Prashant G.P -------------- next part -------------- An HTML attachment was scrubbed... URL: From amauryfa at gmail.com Fri Jul 6 15:30:56 2012 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Fri, 6 Jul 2012 15:30:56 +0200 Subject: [python-win32] How to disable Windows Firewall using WMI In-Reply-To: References: Message-ID: 2012/7/6 prashant padaganur : > c = wmi.WMI("WinMgmts:\root\Microsoft\HomeNet") The \r is a special sequence, interpreted as a "carriage return" character. You should use a raw string: r"WinMgmts:\root\Microsoft\HomeNet" -- Amaury Forgeot d'Arc From prashantpadaganur at gmail.com Fri Jul 6 15:36:36 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Fri, 6 Jul 2012 19:06:36 +0530 Subject: [python-win32] How to disable Windows Firewall using WMI In-Reply-To: References: Message-ID: On Fri, Jul 6, 2012 at 7:00 PM, Amaury Forgeot d'Arc wrote: > 2012/7/6 prashant padaganur : > > c = wmi.WMI("WinMgmts:\root\Microsoft\HomeNet") > > The \r is a special sequence, interpreted as a "carriage return" character. > You should use a raw string: > r"WinMgmts:\root\Microsoft\HomeNet" > > -- > Amaury Forgeot d'Arc > Thanks. But does not help still. I am getting the same com error. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Jul 6 16:12:01 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 06 Jul 2012 15:12:01 +0100 Subject: [python-win32] How to disable Windows Firewall using WMI In-Reply-To: References: Message-ID: <4FF6F231.9020105@timgolden.me.uk> On 06/07/2012 14:36, prashant padaganur wrote: > Thanks. But does not help still. I am getting the same com error. import wmi c = wmi.WMI(namespace="root/Microsoft/HomeNet") for whatever in c.HNet_ConnectionProperties(): print whatever I'm not in a position to try it, but I don't imagine you want the quotes round "False" (that's a string; you want the boolean). And you certainly don't need the Put_ -- the wmi module does that for you. (It has to justify its existence somehow; it doesn't do much else!) TJG From timr at probo.com Fri Jul 6 19:03:02 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 6 Jul 2012 10:03:02 -0700 Subject: [python-win32] How to find the current/last system state from Python In-Reply-To: References: Message-ID: <4FF71A46.6000602@probo.com> prashant padaganur wrote: > > Thanks Tim. But when the system is in S0 state I want to read that information from the system. You want to read WHAT information from the system? Look, here is a complete Python program that accurately tells you the current power state: print "The system is now in S0." If you have a window (even a hidden window), you can grab the WM_POWERBROADCAST message to learn when the system is about to leave S0, and when the system is back in S0 after being in another state, but if you are running, the system is in S0. And that message doesn't tell you which state you are going to or from. > May be as suggested I can try getting the previous states from Windows event logger. So, when you're in S0, you want to know what state we were in the last time we were NOT in S0? I'm not sure there's any reliable way to do that without using a driver. Kernel drivers get reliable messages on each power state transitions that indicate both the old state and the new state. Even a user-mode (UMDF) driver can do that. Perhaps that would solve your issue. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From prashantpadaganur at gmail.com Mon Jul 9 07:16:30 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Mon, 9 Jul 2012 10:46:30 +0530 Subject: [python-win32] How to disable Windows Firewall using WMI In-Reply-To: References: Message-ID: >>On 06/07/2012 14:36, prashant padaganur wrote: >>* Thanks. But does not help still. I am getting the same com error. *> > >import wmi > >c = wmi.WMI(namespace="root/Microsoft/HomeNet") >for whatever in c.HNet_ConnectionProperties(): > print whatever > > > > >I'm not in a position to try it, but I don't imagine you want >the quotes round "False" (that's a string; you want the boolean). >And you certainly don't need the Put_ -- the wmi module does that for >you. (It has to justify its existence somehow; it doesn't do much else!) > >TJG Thanks TJG. It works now. I am able to read/write Hnet_ConnectionProperties(). But I still need to use object.Put_(). But the problem is that when I check from the control panel the actual disabling of Firewall is not happening. I want to do the equivalent of "netsh firewall set opmode mode=disable profile=ALL" c = wmi.WMI(namespace="root/Microsoft/HomeNet") for domain in c.HNet_ConnectionProperties(): print domain domain.IsFirewalled = False domain.IsIcsPrivate = False domain.IsIcsPublic = False domain.Put_() print "After disabling" print domain -------------- next part -------------- An HTML attachment was scrubbed... URL: From Matthew.Thompson2 at shell.com Mon Jul 9 17:58:53 2012 From: Matthew.Thompson2 at shell.com (Matthew.Thompson2 at shell.com) Date: Mon, 9 Jul 2012 15:58:53 +0000 Subject: [python-win32] Application.Visible Inquiry Message-ID: <53DDD5CBD77AAF41BB1B47EC4B25EC790CB5DEF4@seacmw-s-53403.europe.shell.com> Hello, I am currently working on a program that extracts all of the text content out of Microsoft office files (word, powerpoint, excel). I have been able to successfully extract content out of each of the file types using the extension, but there is one strange issue that I have noticed. For powerpoint files, my function requires the line of code: "Application.Visible = True" in order to work. Without that line I get this error: File ">", line 3, in Open com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Office PowerPoint 2007', u'Presentations.Open : Invalid request. The PowerPoint Frame window does not exist.', u'', 0, -2147188160), None) With the doc, docx, xls, and xlsx filetypes, my functions for those types do not require the "Application.Visible = True" line in order to work. I'm wondering if there is anything that can be done to eliminate that line of code from the ppt and pptx function to avoid having to open a new powerpoint window for every file I parse. Any input from on this topic would be greatly appreciated! Thank you, Matthew -------------- next part -------------- An HTML attachment was scrubbed... URL: From janechen_1979 at yahoo.com Fri Jul 13 02:45:10 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Thu, 12 Jul 2012 17:45:10 -0700 (PDT) Subject: [python-win32] ImportError: DLL load failed Message-ID: <1342140310.16733.YahooMailNeo@web164001.mail.gq1.yahoo.com> Hi all, I would like to add python win32 to?Portable Python distribution with PyGTK for Windows?http://fnch.users.sourceforge.net/portablepygtkwindows.html? I installed the pywin32 in the?python\Lib\site-packages folder. PC #1 can find win32api.pyd. After that, I?copied?the whole portable python distribution folder to PC#2. I got the following message: import win32file, win32api ImportError: DLL load failed: The specified module could not be found. Can anyone please help me with this issue? OS: win xp version: pywin32-217 Thanks, Jane -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri Jul 13 03:39:08 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 13 Jul 2012 11:39:08 +1000 Subject: [python-win32] ImportError: DLL load failed In-Reply-To: <1342140310.16733.YahooMailNeo@web164001.mail.gq1.yahoo.com> References: <1342140310.16733.YahooMailNeo@web164001.mail.gq1.yahoo.com> Message-ID: <4FFF7C3C.6090401@gmail.com> On 13/07/2012 10:45 AM, Jane Chen wrote: > Hi all, > > I would like to add python win32 to Portable Python distribution with > PyGTK for Windows > http://fnch.users.sourceforge.net/portablepygtkwindows.html > I installed the pywin32 in the python\Lib\site-packages folder. PC #1 > can find win32api.pyd. After that, I copied the whole portable python > distribution folder to PC#2. I got the following message: > import win32file, win32api > ImportError: DLL load failed: The specified module could not be found. > > Can anyone please help me with this issue? I'm guessing that pywintypes27.dll and pythoncom27.dll aren't anywhere on the PATH on PC#2 - try copying them next to python.exe. HTH, Mark > > OS: win xp > version: pywin32-217 > > Thanks, > Jane > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From janechen_1979 at yahoo.com Fri Jul 13 19:07:46 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Fri, 13 Jul 2012 10:07:46 -0700 (PDT) Subject: [python-win32] ImportError: DLL load failed In-Reply-To: <4FFF7C3C.6090401@gmail.com> References: <1342140310.16733.YahooMailNeo@web164001.mail.gq1.yahoo.com> <4FFF7C3C.6090401@gmail.com> Message-ID: <1342199266.81884.YahooMailNeo@web164004.mail.gq1.yahoo.com> Hi Mark, Thank you for your reply. I copied?pywintypes26.dll and pythoncom26??next to python.exe. and still got the same error message. I printed out the sys.path and it?includes xx\python, xx\python\lib, xx\python\lib\site-packages,xx\python\lib\site-packages\win32, xx\python\lib\site-packages\win32\ lib, and xx\python\lib\site-packages\Pythonwin.? Regards, Jane ________________________________ From: Mark Hammond To: Jane Chen Cc: "python-win32 at python.org" Sent: Thursday, July 12, 2012 6:39 PM Subject: Re: [python-win32] ImportError: DLL load failed On 13/07/2012 10:45 AM, Jane Chen wrote: > Hi all, > > I would like to add python win32 to Portable Python distribution with > PyGTK for Windows > http://fnch.users.sourceforge.net/portablepygtkwindows.html > I installed the pywin32 in the python\Lib\site-packages folder. PC #1 > can find win32api.pyd. After that, I copied the whole portable python > distribution folder to PC#2. I got the following message: > import win32file, win32api > ImportError: DLL load failed: The specified module could not be found. > > Can anyone please help me with this issue? I'm guessing that pywintypes27.dll and pythoncom27.dll aren't anywhere on the PATH on PC#2 - try copying them next to python.exe. HTH, Mark > > OS: win xp > version: pywin32-217 > > Thanks, > Jane > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Mon Jul 16 08:42:36 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 16 Jul 2012 16:42:36 +1000 Subject: [python-win32] ImportError: DLL load failed In-Reply-To: <1342199266.81884.YahooMailNeo@web164004.mail.gq1.yahoo.com> References: <1342140310.16733.YahooMailNeo@web164001.mail.gq1.yahoo.com> <4FFF7C3C.6090401@gmail.com> <1342199266.81884.YahooMailNeo@web164004.mail.gq1.yahoo.com> Message-ID: <5003B7DC.2000203@gmail.com> My only other guess is that the C runtime DLLs are missing - msvcr90.dll et al. If they seem to be in place, try grabbing the "depends" module from the MS sysinternals site and see what it reports. Cheers, Mark On 14/07/2012 3:07 AM, Jane Chen wrote: > Hi Mark, > > Thank you for your reply. I copied pywintypes26.dll and pythoncom26 next > to python.exe. and still got the same error message. I printed out the > sys.path and it includes xx\python, xx\python\lib, > xx\python\lib\site-packages,xx\python\lib\site-packages\win32, > xx\python\lib\site-packages\win32\ lib, and > xx\python\lib\site-packages\Pythonwin. > > Regards, > Jane > > ------------------------------------------------------------------------ > *From:* Mark Hammond > *To:* Jane Chen > *Cc:* "python-win32 at python.org" > *Sent:* Thursday, July 12, 2012 6:39 PM > *Subject:* Re: [python-win32] ImportError: DLL load failed > > On 13/07/2012 10:45 AM, Jane Chen wrote: > > Hi all, > > > > I would like to add python win32 to Portable Python distribution with > > PyGTK for Windows > > http://fnch.users.sourceforge.net/portablepygtkwindows.html > > I installed the pywin32 in the python\Lib\site-packages folder. PC #1 > > can find win32api.pyd. After that, I copied the whole portable python > > distribution folder to PC#2. I got the following message: > > import win32file, win32api > > ImportError: DLL load failed: The specified module could not be found. > > > > Can anyone please help me with this issue? > > I'm guessing that pywintypes27.dll and pythoncom27.dll aren't anywhere > on the PATH on PC#2 - try copying them next to python.exe. > > HTH, > > Mark > > > > > OS: win xp > > version: pywin32-217 > > > > Thanks, > > Jane > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From ferdinandsousa at gmail.com Mon Jul 16 13:52:11 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Mon, 16 Jul 2012 17:22:11 +0530 Subject: [python-win32] Take Screenshot when you log in remotely [Win 7 Pro] Message-ID: Hi Tim, Thanks a lot for the inputs. Earlier (Win Xp I think), I was told (erroneously?) that using the /console switch with the mstsc command would enable you to connect into a currently running local user session. Is this info incorrect? Or is it that you are able to connect to the said session, but it changes to a remote session? I would tend to think it is the latter. Also, now with Win 7 (client is Professional and machine I'm connecting to is also Professional) mstsc seems to no longer have the /console switch. I guess I just have to bite the bullet and work with this. My **specific issue** is that my scenario works pretty well with task scheduling and leaving the local session locked. However, if I log in remotely using the same user (session become remote I guess), or even a different user (disconnects the local user's session) the screenshot can no longer be taken. Best regards, Ferdi > ---------- Forwarded message ---------- > From: Tim Roberts > To: "python-win32 at python.org" > Cc: "image-sig-request at python.org" > Date: Thu, 5 Jul 2012 10:24:51 -0700 > Subject: Re: [python-win32] Take Screenshot when you log in remotely [Win > 7 Pro] > Ferdinand Sousa wrote: > > > > I have written a script that uses the screenshot() function from the > > ImageGrab module of the Python Imaging library and I would like to run > > this script as a scheduled task. > > > > Now for the issues. In the task scheduler, if I select 'Run whether > > user is logged on or not', it does run, but the scheduler shows it as > > failed to run. This happens both when logged in or if logged in and > > session is locked > > > > So, I chose to use the 'Run only when user is logged on' option. Now, > > this works well, when logged on as well as if the session is locked. > > The problem is if I try to login remotely via RDP this stops working > > the moment I disconnect. > > Right. When you disconnect the session, there no longer is any screen > to take a shot of. Screenshots are implemented by calling the graphics > driver. A disconnected session does not have a graphics driver. > Windows does not keep a backing store copy of a session's frame buffer > anywhere. When a disconnected session is reconnected, all of the > applications are sent "paint" messages to force the screen to be > repainted from scratch. > > > > Is there any option I could use to make it work under 'Run whether > > user is logged on or not' Task scheduler option? > > Maybe I could reduce the privilege level needed to execute python.exe? > > That won't help. What you ask is simply not possible. The bits you > want to grab do not exist. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From janechen_1979 at yahoo.com Mon Jul 16 23:31:24 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Mon, 16 Jul 2012 14:31:24 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation (IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? Message-ID: <1342474284.54934.YahooMailNeo@web164004.mail.gq1.yahoo.com> Hi All, Does pywin32 support SD card operation (IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? ?I google?IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL with Python. However, no useful information shows up.? My code: if win32file.DeviceIoControl(hVol, winioctlcon.IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL, 0, 6, 0): Error message: AttributeError: 'module' object has no attribute "IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL". Thank you, Jane -------------- next part -------------- An HTML attachment was scrubbed... URL: From matteo.boscolo at boscolini.eu Tue Jul 17 00:37:21 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Tue, 17 Jul 2012 00:37:21 +0200 Subject: [python-win32] problem After compiling with py2exe on a com class Message-ID: <500497A1.908@boscolini.eu> Hi all, I got a com server that is crated inside a cad application. if i run the following code(That is a method of my com class): def showWindows(self): """ show a qt windows with a button """ try: logging.info("showWindows .....") nDocument=str(self.td.Documents.Count) form=EditInputBox(nDocument) # <-- this is a pyqt dialog form.exec_() logging.info("After Exec %s"%str(self.td.Documents.Count)) return S_OK except: print_exc_plus() return 1 and I'm using the normal python source script, all work ok. but if I py2exe the com server,( .exe ) and i run the some code, and I leave the dialog opened for more than a minute I got the following exception from the self.td.Documents.Count that is a method of the cad application. It seems a problem releted to a timeout or releted to the garbage collector. Any Idea in how to debug it or how to find a solution to this problem is really appreciated. regards Matteo ERROR:root:******************** ERROR:root: ERROR:root:(-2147417856, 'System call failed.', None, None) ERROR:root: ERROR:root:******************** ERROR:root:Locals by frame, innermost last ERROR:root:Frame in boot_com_servers.py at line 112 ERROR:root: get_classes = ERROR:root: DllUnregisterServer = ERROR:root: arg = /automate ERROR:root: clsids = ['{1E685399-2991-4E3D-8217-22DE9CFBEAF6}'] ERROR:root: __package__ = None ERROR:root: com_module_names = ['testCom'] ERROR:root: __doc__ = None ERROR:root: zipextimporter = ERROR:root: __builtins__ = ERROR:root: sys = ERROR:root: __name__ = __main__ ERROR:root: com_modules = [] ERROR:root: DllRegisterServer = ERROR:root: i = 1 ERROR:root: k = ERROR:root: m = ERROR:root: DllInstall = ERROR:root: win32com = ERROR:root: pythoncom = ERROR:root: win32api = ERROR:root:Frame serve in win32com\server\localserver.pyc at line 36 ERROR:root: infos = [(, 16)] ERROR:root: clsids = ['{1E685399-2991-4E3D-8217-22DE9CFBEAF6}'] ERROR:root:Frame _Invoke_ in win32com\server\policy.pyc at line 277 ERROR:root: wFlags = 3 ERROR:root: args = () ERROR:root: lcid = 0 ERROR:root: dispid = 1001 ERROR:root: self = ERROR:root:Frame _invoke_ in win32com\server\policy.pyc at line 282 ERROR:root: wFlags = 3 ERROR:root: args = () ERROR:root: lcid = 0 ERROR:root: dispid = 1001 ERROR:root: self = ERROR:root:Frame _invokeex_ in win32com\server\policy.pyc at line 585 ERROR:root: serviceProvider = None ERROR:root: self = ERROR:root: args = () ERROR:root: dispid = 1001 ERROR:root: funcname = showWindows ERROR:root: wFlags = 3 ERROR:root: lcid = 0 ERROR:root: func = > ERROR:root: kwArgs = None ERROR:root:Frame showWindows in testCom.pyc at line 133 ERROR:root: self = ERROR:root: nDocument = 1 ERROR:root: form = ERROR:root:Frame __getattr__ in win32com\client\__init__.pyc at line 466 ERROR:root: self = ERROR:root: args = (11, 2, (9, 0), (), 'Documents', '{91D219D5-0F56-11D3-BD73-00500400405B}') ERROR:root: attr = Documents ERROR:root:Frame _ApplyTypes_ in win32com\client\__init__.pyc at line 459 ERROR:root: resultCLSID = {91D219D5-0F56-11D3-BD73-00500400405B} ERROR:root: dispid = 11 ERROR:root: self = ERROR:root: args = () ERROR:root: retType = (9, 0) ERROR:root: argTypes = () ERROR:root: wFlags = 2 ERROR:root: user = Documents From skippy.hammond at gmail.com Tue Jul 17 03:19:22 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 17 Jul 2012 11:19:22 +1000 Subject: [python-win32] problem After compiling with py2exe on a com class In-Reply-To: <500497A1.908@boscolini.eu> References: <500497A1.908@boscolini.eu> Message-ID: <5004BD9A.4040603@gmail.com> On 17/07/2012 8:37 AM, Matteo Boscolo wrote: > Hi all, > > I got a com server that is crated inside a cad application. > > if i run the following code(That is a method of my com class): > > def showWindows(self): > """ > show a qt windows with a button > """ > try: > logging.info("showWindows .....") > nDocument=str(self.td.Documents.Count) > form=EditInputBox(nDocument) # <-- this is a pyqt dialog > form.exec_() > logging.info("After Exec %s"%str(self.td.Documents.Count)) > return S_OK > except: > print_exc_plus() > return 1 > > and I'm using the normal python source script, all work ok. > > but if I py2exe the com server,( .exe ) When you run it from normal Python, is the .exe or .dll version of the object used? Depending on the creator of the object, the default is likely to be the inproc (ie, dll) version. You should verify this and ensure py2exe creates the same kind of server. Apart from that, I'm afraid I have no idea... HTH, Mark and i run the some code, and I > leave the dialog opened for more than a minute I got the following > exception from the self.td.Documents.Count that is a method of the cad > application. > > It seems a problem releted to a timeout or releted to the garbage > collector. > Any Idea in how to debug it or how to find a solution to this problem is > really appreciated. > > regards > Matteo > > > ERROR:root:******************** > ERROR:root: > ERROR:root:(-2147417856, 'System call failed.', None, None) > ERROR:root: > ERROR:root:******************** > ERROR:root:Locals by frame, innermost last > ERROR:root:Frame in boot_com_servers.py at line 112 > ERROR:root: get_classes = > ERROR:root: DllUnregisterServer = 0x02D5C470> > ERROR:root: arg = /automate > ERROR:root: clsids = > ['{1E685399-2991-4E3D-8217-22DE9CFBEAF6}'] > ERROR:root: __package__ = None > ERROR:root: com_module_names = ['testCom'] > ERROR:root: __doc__ = None > ERROR:root: zipextimporter = 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\zipextimporter.pyc'> > > ERROR:root: __builtins__ = > ERROR:root: sys = > ERROR:root: __name__ = __main__ > ERROR:root: com_modules = [ 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\testCom.pyc'>] > > ERROR:root: DllRegisterServer = 0x02D5C330> > ERROR:root: i = 1 > ERROR:root: k = > ERROR:root: m = 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\testCom.pyc'> > > ERROR:root: DllInstall = > ERROR:root: win32com = 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\win32com\__init__.pyc'> > > ERROR:root: pythoncom = 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\pythoncom27.dll'> > > ERROR:root: win32api = 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\win32api.pyd'> > > ERROR:root:Frame serve in win32com\server\localserver.pyc at line 36 > ERROR:root: infos = [( with obj at 0x02F43B08>, 16)] > ERROR:root: clsids = > ['{1E685399-2991-4E3D-8217-22DE9CFBEAF6}'] > ERROR:root:Frame _Invoke_ in win32com\server\policy.pyc at line 277 > ERROR:root: wFlags = 3 > ERROR:root: args = () > ERROR:root: lcid = 0 > ERROR:root: dispid = 1001 > ERROR:root: self = > > ERROR:root:Frame _invoke_ in win32com\server\policy.pyc at line 282 > ERROR:root: wFlags = 3 > ERROR:root: args = () > ERROR:root: lcid = 0 > ERROR:root: dispid = 1001 > ERROR:root: self = > > ERROR:root:Frame _invokeex_ in win32com\server\policy.pyc at line 585 > ERROR:root: serviceProvider = None > ERROR:root: self = > > ERROR:root: args = () > ERROR:root: dispid = 1001 > ERROR:root: funcname = showWindows > ERROR:root: wFlags = 3 > ERROR:root: lcid = 0 > ERROR:root: func = TestComInterface.showWindows of 0x02D72810>> > ERROR:root: kwArgs = None > ERROR:root:Frame showWindows in testCom.pyc at line 133 > ERROR:root: self = at 0x02D72810> > ERROR:root: nDocument = 1 > ERROR:root: form = 0x05482588> > ERROR:root:Frame __getattr__ in win32com\client\__init__.pyc at line 466 > ERROR:root: self = thinkdesign Type Library.IApplication instance at 0x49209832> > ERROR:root: args = (11, 2, (9, 0), (), 'Documents', > '{91D219D5-0F56-11D3-BD73-00500400405B}') > ERROR:root: attr = Documents > ERROR:root:Frame _ApplyTypes_ in win32com\client\__init__.pyc at line 459 > ERROR:root: resultCLSID = > {91D219D5-0F56-11D3-BD73-00500400405B} > ERROR:root: dispid = 11 > ERROR:root: self = thinkdesign Type Library.IApplication instance at 0x49209832> > ERROR:root: args = () > ERROR:root: retType = (9, 0) > ERROR:root: argTypes = () > ERROR:root: wFlags = 2 > ERROR:root: user = Documents > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From rupole at hotmail.com Tue Jul 17 03:54:03 2012 From: rupole at hotmail.com (Roger Upole) Date: Mon, 16 Jul 2012 21:54:03 -0400 Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? References: <1342474284.54934.YahooMailNeo@web164004.mail.gq1.yahoo.com> Message-ID: That one isn't in winioctlcon.py yet, but you should be able to define it relatively easily. According to the headers: #define IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL \ CTL_CODE( FILE_DEVICE_DISK, 0x7a0, METHOD_BUFFERED, FILE_ANY_ACCESS) You'll probably need to create the output buffer yourself and initialize the Size correctly. typedef struct _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA { USHORT Size; USHORT Reserved; GUID ProtocolGUID; } Roger From matteo.boscolo at boscolini.eu Tue Jul 17 08:12:21 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Tue, 17 Jul 2012 08:12:21 +0200 Subject: [python-win32] problem After compiling with py2exe on a com class In-Reply-To: <5004BD9A.4040603@gmail.com> References: <500497A1.908@boscolini.eu> <5004BD9A.4040603@gmail.com> Message-ID: <50050245.3070600@boscolini.eu> Il 17/07/2012 03:19, Mark Hammond ha scritto: > On 17/07/2012 8:37 AM, Matteo Boscolo wrote: >> Hi all, >> >> I got a com server that is crated inside a cad application. >> >> if i run the following code(That is a method of my com class): >> >> def showWindows(self): >> """ >> show a qt windows with a button >> """ >> try: >> logging.info("showWindows .....") >> nDocument=str(self.td.Documents.Count) >> form=EditInputBox(nDocument) # <-- this is a pyqt dialog >> form.exec_() >> logging.info("After Exec %s"%str(self.td.Documents.Count)) >> return S_OK >> except: >> print_exc_plus() >> return 1 >> >> and I'm using the normal python source script, all work ok. >> >> but if I py2exe the com server,( .exe ) > > When you run it from normal Python, is the .exe or .dll version of the > object used? it's an exe file not a dll > Depending on the creator of the object, the default is likely to be > the inproc (ie, dll) version. You should verify this and ensure > py2exe creates the same kind of server. > > Apart from that, I'm afraid I have no idea... > > HTH, > > Mark > > > and i run the some code, and I >> leave the dialog opened for more than a minute I got the following >> exception from the self.td.Documents.Count that is a method of the cad >> application. >> >> It seems a problem releted to a timeout or releted to the garbage >> collector. >> Any Idea in how to debug it or how to find a solution to this problem is >> really appreciated. >> >> regards >> Matteo >> >> >> ERROR:root:******************** >> ERROR:root: >> ERROR:root:(-2147417856, 'System call failed.', None, None) >> ERROR:root: >> ERROR:root:******************** >> ERROR:root:Locals by frame, innermost last >> ERROR:root:Frame in boot_com_servers.py at line 112 >> ERROR:root: get_classes = > 0x02C134F0> >> ERROR:root: DllUnregisterServer = > 0x02D5C470> >> ERROR:root: arg = /automate >> ERROR:root: clsids = >> ['{1E685399-2991-4E3D-8217-22DE9CFBEAF6}'] >> ERROR:root: __package__ = None >> ERROR:root: com_module_names = ['testCom'] >> ERROR:root: __doc__ = None >> ERROR:root: zipextimporter = > 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\zipextimporter.pyc'> >> >> >> ERROR:root: __builtins__ = >> ERROR:root: sys = >> ERROR:root: __name__ = __main__ >> ERROR:root: com_modules = [> 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\testCom.pyc'>] >> >> >> ERROR:root: DllRegisterServer = > 0x02D5C330> >> ERROR:root: i = 1 >> ERROR:root: k = >> ERROR:root: m = > 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\testCom.pyc'> >> >> >> ERROR:root: DllInstall = > 0x02D5C4B0> >> ERROR:root: win32com = > 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\win32com\__init__.pyc'> >> >> >> ERROR:root: pythoncom = > 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\pythoncom27.dll'> >> >> >> ERROR:root: win32api = > 'C:\d\OMNIAS~1\PROGRA~1\ECLIPS~1\ALLPUR~1\THINKD~1\TestCom\dist\testCom.exe\win32api.pyd'> >> >> >> ERROR:root:Frame serve in win32com\server\localserver.pyc at line 36 >> ERROR:root: infos = [(> with obj at 0x02F43B08>, 16)] >> ERROR:root: clsids = >> ['{1E685399-2991-4E3D-8217-22DE9CFBEAF6}'] >> ERROR:root:Frame _Invoke_ in win32com\server\policy.pyc at line 277 >> ERROR:root: wFlags = 3 >> ERROR:root: args = () >> ERROR:root: lcid = 0 >> ERROR:root: dispid = 1001 >> ERROR:root: self = >> >> ERROR:root:Frame _invoke_ in win32com\server\policy.pyc at line 282 >> ERROR:root: wFlags = 3 >> ERROR:root: args = () >> ERROR:root: lcid = 0 >> ERROR:root: dispid = 1001 >> ERROR:root: self = >> >> ERROR:root:Frame _invokeex_ in win32com\server\policy.pyc at line 585 >> ERROR:root: serviceProvider = None >> ERROR:root: self = >> >> ERROR:root: args = () >> ERROR:root: dispid = 1001 >> ERROR:root: funcname = showWindows >> ERROR:root: wFlags = 3 >> ERROR:root: lcid = 0 >> ERROR:root: func = > TestComInterface.showWindows of > 0x02D72810>> >> ERROR:root: kwArgs = None >> ERROR:root:Frame showWindows in testCom.pyc at line 133 >> ERROR:root: self = > at 0x02D72810> >> ERROR:root: nDocument = 1 >> ERROR:root: form = > 0x05482588> >> ERROR:root:Frame __getattr__ in win32com\client\__init__.pyc at line 466 >> ERROR:root: self = > thinkdesign Type Library.IApplication instance at 0x49209832> >> ERROR:root: args = (11, 2, (9, 0), (), 'Documents', >> '{91D219D5-0F56-11D3-BD73-00500400405B}') >> ERROR:root: attr = Documents >> ERROR:root:Frame _ApplyTypes_ in win32com\client\__init__.pyc at line >> 459 >> ERROR:root: resultCLSID = >> {91D219D5-0F56-11D3-BD73-00500400405B} >> ERROR:root: dispid = 11 >> ERROR:root: self = > thinkdesign Type Library.IApplication instance at 0x49209832> >> ERROR:root: args = () >> ERROR:root: retType = (9, 0) >> ERROR:root: argTypes = () >> ERROR:root: wFlags = 2 >> ERROR:root: user = Documents >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > > From kurt.munson at hbmncode.com Tue Jul 17 15:51:49 2012 From: kurt.munson at hbmncode.com (Kurt Munson) Date: Tue, 17 Jul 2012 14:51:49 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously Message-ID: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> I have been using pywin32 successfully for years to control Excel. Now, suddenly I get errors executing the same code that has run previously. My python code controls Excel like this: import win32com.client xl = win32com.client.DispatchEx("Excel.Application") xl.DisplayAlerts = 0 xl.visible = 0 The last line('xl.visible = 0') now causes an error: '' object has no attribute 'visible' [Function: glyphscript Line:63 | Function: __setattr__ Line:470] This error goes away if I use xl.Visible instead of xl.visible - notice the uppercase V. But then I get all sorts of other errors, in places that didn't error previously. Why would this code have worked for years, and then suddenly not work now? I am using Python 2.6.5 and pywin32-214 on 64 bit Windows 7. I uninstalled and reinstalled Python and pywin32, but the new errors persist. -Kurt ________________________________ Confidentiality Notice: This email may contain confidential and/or privileged information. If you are not the intended recipient of this message, please delete it immediately and inform the sender that you have received this message in error. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 17 16:00:02 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 17 Jul 2012 15:00:02 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> Message-ID: <50056FE2.1080602@timgolden.me.uk> On 17/07/2012 14:51, Kurt Munson wrote: > I have been using pywin32 successfully for years to control Excel. Now, > suddenly I get errors executing the same code that has run previously. [...] > The last line(?xl.visible = 0?) now causes an error: [...] > This error goes away if I use xl.Visible instead of xl.visible ? notice > the uppercase V. But then I get all sorts of other errors, in places > that didn?t error previously. You've almost certainly switched from using dynamic (or late-binding) Dispatch to using static (or early-binding) Dispatch. Dynamic dispatch simply hands off all attribute access to the underlying COM object which is not case-sensitive. Static dispatch creates an actual Python module which -- like all Python code -- is case-sensitive. You can force dynamic dispatch by using: import win32com.client xl = win32com.client.dynamic.Dispatch("Excel.Application") Apart of the case-sensitivity, BTW, the clue is also in the traceback you posted which includes the win32com.gen_py prefix, indicating that it's using a generated Python module. TJG From mail at timgolden.me.uk Tue Jul 17 16:26:45 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 17 Jul 2012 15:26:45 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> Message-ID: <50057625.8040101@timgolden.me.uk> [cc-ing the list back in so you get the benefit of more and greater intelligences...] On 17/07/2012 15:20, Kurt Munson wrote: > I don't get it: I haven't made any changes to that Dispatch call in > months! > > My code worked for months with the existing Dispatch method, up > through yesterday afternoon, then began returning errors this > morning. How could this be? Well maybe I'm wrong. Someone else might have a better idea, but it's a classic symptom of this issue. What does your Dispatch code look like? TJG From kurt.munson at hbmncode.com Tue Jul 17 17:05:14 2012 From: kurt.munson at hbmncode.com (Kurt Munson) Date: Tue, 17 Jul 2012 16:05:14 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <50057625.8040101@timgolden.me.uk> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> Message-ID: <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> Dunno exactly what you mean by "what's your Dispatch code look like". If you mean what am I doing with Excel via Python, it's like this: it creates an Excel spreadsheet, adds a bunch of content, formats cells, etc. All of this worked beautifully until this morning. Here is a little bit of the code I am using to control Excel: import win32com.client xl = win32com.client.DispatchEx("Excel.Application") # other stuff xl.DisplayAlerts = 0 xl.Visible = 0 # more other stuff currentSheet.Range("A1:B1").EntireColumn.AutoFit # more more other stuff plotbutton = currentSheet.buttons.Add(300, 8, 80, 45) Incidentally, I tried changing the dispatch line to use dynamic dispatch using this code: xl = win32com.client.dynamic.Dispatch("Excel.Application") ...and I still run into apparent case sensitivity, like not recognizing xl.visible, in lower case. I thought dynamic dispatch would remove case sensitivity. -Kurt -----Original Message----- From: Tim Golden [mailto:mail at timgolden.me.uk] Sent: Tuesday, July 17, 2012 10:27 AM To: Kurt Munson; python-win32 at python.org Subject: Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously [cc-ing the list back in so you get the benefit of more and greater intelligences...] On 17/07/2012 15:20, Kurt Munson wrote: > I don't get it: I haven't made any changes to that Dispatch call in > months! > > My code worked for months with the existing Dispatch method, up > through yesterday afternoon, then began returning errors this morning. > How could this be? Well maybe I'm wrong. Someone else might have a better idea, but it's a classic symptom of this issue. What does your Dispatch code look like? TJG Confidentiality Notice: This email may contain confidential and/or privileged information. If you are not the intended recipient of this message, please delete it immediately and inform the sender that you have received this message in error. From mail at timgolden.me.uk Tue Jul 17 17:20:16 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 17 Jul 2012 16:20:16 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> Message-ID: <500582B0.6000304@timgolden.me.uk> On 17/07/2012 16:05, Kurt Munson wrote: > Dunno exactly what you mean by "what's your Dispatch code look > like". Well pretty much what you posted, in fact :) > Incidentally, I tried changing the dispatch line to use dynamic > dispatch using this code: > > xl = win32com.client.dynamic.Dispatch("Excel.Application") > > > ...and I still run into apparent case sensitivity, like not > recognizing xl.visible, in lower case. I thought dynamic dispatch > would remove case sensitivity. So did I: ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 2.7.1 (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 Type "help", "copyright", "credits" or "license" for more infor >>> import win32com.client >>> xl = win32com.client.dynamic.Dispatch("Excel.Application") >>> xl.visible False >>> xl.Visible False >>> >>> whereas: >>> xl2 = win32com.client.gencache.EnsureDispatch("Excel.Application") >>> xl2.visible Traceback (most recent call last): File "", line 1, in File "c:\python27\lib\site-packages\win32com\client\__init__.py", line 462, in __getattr__ raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) AttributeError: '' object has no attribute 'visible' >>> Well I'm stumped. Hopefully someone more knowledgeable can chip in. TJG From graham.bloice at trihedral.com Tue Jul 17 17:31:04 2012 From: graham.bloice at trihedral.com (Graham Bloice) Date: Tue, 17 Jul 2012 16:31:04 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <500582B0.6000304@timgolden.me.uk> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> Message-ID: > -----Original Message----- > Subject: Re: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > On 17/07/2012 16:05, Kurt Munson wrote: > > Dunno exactly what you mean by "what's your Dispatch code look like". > > Well pretty much what you posted, in fact :) > > > Incidentally, I tried changing the dispatch line to use dynamic > > dispatch using this code: > > > > xl = win32com.client.dynamic.Dispatch("Excel.Application") > > > > > > ...and I still run into apparent case sensitivity, like not > > recognizing xl.visible, in lower case. I thought dynamic dispatch > > would remove case sensitivity. > > So did I: > > > ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 2.7.1 > (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 Type "help", "copyright", > "credits" or "license" for more infor > >>> import win32com.client > >>> xl = win32com.client.dynamic.Dispatch("Excel.Application") > >>> xl.visible > False > >>> xl.Visible > False > >>> > >>> > > > > whereas: > > > >>> xl2 = win32com.client.gencache.EnsureDispatch("Excel.Application") > >>> xl2.visible > Traceback (most recent call last): > File "", line 1, in > File "c:\python27\lib\site-packages\win32com\client\__init__.py", line 462, > in __getattr__ > raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) > AttributeError: ' Library._Application instance at 0x58072680>' object has no attribute 'visible' > >>> > > > > Well I'm stumped. Hopefully someone more knowledgeable can chip in. > [Graham Bloice said] Maybe remove the generated early binding .py for Excel in win32com\gen_py From kurt.munson at hbmncode.com Tue Jul 17 17:46:05 2012 From: kurt.munson at hbmncode.com (Kurt Munson) Date: Tue, 17 Jul 2012 16:46:05 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> Message-ID: <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> There almost nothing in C:\Python26\Lib\site-packages\win32com\gen_py. In a subfolder \00020813-0000-0000-C000-000000000046x0x1x7, I have 30 .py and .pyc, all generated in the last day. Are you saying that they should be removed? -Kurt -----Original Message----- From: python-win32-bounces+kurt.munson=hbmncode.com at python.org [mailto:python-win32-bounces+kurt.munson=hbmncode.com at python.org] On Behalf Of Graham Bloice Sent: Tuesday, July 17, 2012 11:31 AM To: python-win32 at python.org Subject: Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously > -----Original Message----- > Subject: Re: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > On 17/07/2012 16:05, Kurt Munson wrote: > > Dunno exactly what you mean by "what's your Dispatch code look like". > > Well pretty much what you posted, in fact :) > > > Incidentally, I tried changing the dispatch line to use dynamic > > dispatch using this code: > > > > xl = win32com.client.dynamic.Dispatch("Excel.Application") > > > > > > ...and I still run into apparent case sensitivity, like not > > recognizing xl.visible, in lower case. I thought dynamic dispatch > > would remove case sensitivity. > > So did I: > > > ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 2.7.1 > (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 Type "help", "copyright", > "credits" or "license" for more infor > >>> import win32com.client > >>> xl = win32com.client.dynamic.Dispatch("Excel.Application") > >>> xl.visible > False > >>> xl.Visible > False > >>> > >>> > > > > whereas: > > > >>> xl2 = win32com.client.gencache.EnsureDispatch("Excel.Application") > >>> xl2.visible > Traceback (most recent call last): > File "", line 1, in > File "c:\python27\lib\site-packages\win32com\client\__init__.py", > line 462, > in __getattr__ > raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) > AttributeError: ' Library._Application instance at 0x58072680>' object has no attribute 'visible' > >>> > > > > Well I'm stumped. Hopefully someone more knowledgeable can chip in. > [Graham Bloice said] Maybe remove the generated early binding .py for Excel in win32com\gen_py _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Confidentiality Notice: This email may contain confidential and/or privileged information. If you are not the intended recipient of this message, please delete it immediately and inform the sender that you have received this message in error. From graham.bloice at trihedral.com Tue Jul 17 17:55:56 2012 From: graham.bloice at trihedral.com (Graham Bloice) Date: Tue, 17 Jul 2012 16:55:56 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> Message-ID: > -----Original Message----- > From: Kurt Munson [mailto:kurt.munson at hbmncode.com] > Sent: 17 July 2012 16:46 > To: Graham Bloice; python-win32 at python.org > Subject: RE: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > There almost nothing in C:\Python26\Lib\site-packages\win32com\gen_py. > > In a subfolder \00020813-0000-0000-C000-000000000046x0x1x7, I have 30 .py > and .pyc, all generated in the last day. > > Are you saying that they should be removed? > [Graham Bloice said] Have a quick look at them and if they are all for Excel interfaces, yes. I have a vague recollection that even dynamic dispatch will use the generated files if present. > > -----Original Message----- > From: python-win32-bounces+kurt.munson=hbmncode.com at python.org > [mailto:python-win32-bounces+kurt.munson=hbmncode.com at python.org] > On Behalf Of Graham Bloice > Sent: Tuesday, July 17, 2012 11:31 AM > To: python-win32 at python.org > Subject: Re: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > > -----Original Message----- > > Subject: Re: [python-win32] new Pywin32 errors stating 'object has no > > attribute' - and the code worked previously > > > > On 17/07/2012 16:05, Kurt Munson wrote: > > > Dunno exactly what you mean by "what's your Dispatch code look like". > > > > Well pretty much what you posted, in fact :) > > > > > Incidentally, I tried changing the dispatch line to use dynamic > > > dispatch using this code: > > > > > > xl = win32com.client.dynamic.Dispatch("Excel.Application") > > > > > > > > > ...and I still run into apparent case sensitivity, like not > > > recognizing xl.visible, in lower case. I thought dynamic dispatch > > > would remove case sensitivity. > > > > So did I: > > > > > > ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python 2.7.1 > > (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 Type "help", > "copyright", > > "credits" or "license" for more infor > > >>> import win32com.client > > >>> xl = win32com.client.dynamic.Dispatch("Excel.Application") > > >>> xl.visible > > False > > >>> xl.Visible > > False > > >>> > > >>> > > > > > > > > whereas: > > > > > > >>> xl2 = win32com.client.gencache.EnsureDispatch("Excel.Application") > > >>> xl2.visible > > Traceback (most recent call last): > > File "", line 1, in > > File "c:\python27\lib\site-packages\win32com\client\__init__.py", > > line > 462, > > in __getattr__ > > raise AttributeError("'%s' object has no attribute '%s'" % > (repr(self), attr)) > > AttributeError: ' > Library._Application instance at 0x58072680>' object has no attribute > 'visible' > > >>> > > > > > > > > Well I'm stumped. Hopefully someone more knowledgeable can chip in. > > > [Graham Bloice said] > > Maybe remove the generated early binding .py for Excel in > win32com\gen_py > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > Confidentiality Notice: This email may contain confidential and/or privileged > information. If you are not the intended recipient of this message, please > delete it immediately and inform the sender that you have received this > message in error. From kurt.munson at hbmncode.com Tue Jul 17 18:08:22 2012 From: kurt.munson at hbmncode.com (Kurt Munson) Date: Tue, 17 Jul 2012 17:08:22 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> Message-ID: <44BAEB2C477352489FFEC99834169BB3225EAE9E@nova.ncode.com> Graham, Thanks for the suggestion - deleting the \win32com\gen_py .py and .pyc files solved the problem! It appears that my dispatch (whether static or dynamic) was using old generated py instead of regenerating. Why would this be? Either way, deleting the folder under \win32com\gen_py solved this problem. Thanks again for the help. -Kurt -----Original Message----- From: python-win32-bounces+kurt.munson=hbmncode.com at python.org [mailto:python-win32-bounces+kurt.munson=hbmncode.com at python.org] On Behalf Of Graham Bloice Sent: Tuesday, July 17, 2012 11:56 AM To: python-win32 at python.org Subject: Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously > -----Original Message----- > From: Kurt Munson [mailto:kurt.munson at hbmncode.com] > Sent: 17 July 2012 16:46 > To: Graham Bloice; python-win32 at python.org > Subject: RE: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > There almost nothing in C:\Python26\Lib\site-packages\win32com\gen_py. > > In a subfolder \00020813-0000-0000-C000-000000000046x0x1x7, I have 30 .py > and .pyc, all generated in the last day. > > Are you saying that they should be removed? > [Graham Bloice said] Have a quick look at them and if they are all for Excel interfaces, yes. I have a vague recollection that even dynamic dispatch will use the generated files if present. > > -----Original Message----- > From: python-win32-bounces+kurt.munson=hbmncode.com at python.org > [mailto:python-win32-bounces+kurt.munson=hbmncode.com at python.org] > On Behalf Of Graham Bloice > Sent: Tuesday, July 17, 2012 11:31 AM > To: python-win32 at python.org > Subject: Re: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > > -----Original Message----- > > Subject: Re: [python-win32] new Pywin32 errors stating 'object has > > no attribute' - and the code worked previously > > > > On 17/07/2012 16:05, Kurt Munson wrote: > > > Dunno exactly what you mean by "what's your Dispatch code look like". > > > > Well pretty much what you posted, in fact :) > > > > > Incidentally, I tried changing the dispatch line to use dynamic > > > dispatch using this code: > > > > > > xl = win32com.client.dynamic.Dispatch("Excel.Application") > > > > > > > > > ...and I still run into apparent case sensitivity, like not > > > recognizing xl.visible, in lower case. I thought dynamic dispatch > > > would remove case sensitivity. > > > > So did I: > > > > > > ActivePython 2.7.1.4 (ActiveState Software Inc.) based on Python > > 2.7.1 (r271:86832, Feb 7 2011, 11:30:38) [MSC v.1500 32 Type > > "help", > "copyright", > > "credits" or "license" for more infor > > >>> import win32com.client > > >>> xl = win32com.client.dynamic.Dispatch("Excel.Application") > > >>> xl.visible > > False > > >>> xl.Visible > > False > > >>> > > >>> > > > > > > > > whereas: > > > > > > >>> xl2 = > > >>> win32com.client.gencache.EnsureDispatch("Excel.Application") > > >>> xl2.visible > > Traceback (most recent call last): > > File "", line 1, in > > File "c:\python27\lib\site-packages\win32com\client\__init__.py", > > line > 462, > > in __getattr__ > > raise AttributeError("'%s' object has no attribute '%s'" % > (repr(self), attr)) > > AttributeError: ' > Library._Application instance at 0x58072680>' object has no > > attribute > 'visible' > > >>> > > > > > > > > Well I'm stumped. Hopefully someone more knowledgeable can chip in. > > > [Graham Bloice said] > > Maybe remove the generated early binding .py for Excel in > win32com\gen_py _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > Confidentiality Notice: This email may contain confidential and/or privileged > information. If you are not the intended recipient of this message, please > delete it immediately and inform the sender that you have received > this message in error. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From graham.bloice at trihedral.com Tue Jul 17 18:10:14 2012 From: graham.bloice at trihedral.com (Graham Bloice) Date: Tue, 17 Jul 2012 17:10:14 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <44BAEB2C477352489FFEC99834169BB3225EAE9E@nova.ncode.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> <44BAEB2C477352489FFEC99834169BB3225EAE9E@nova.ncode.com> Message-ID: > -----Original Message----- > From: python-win32-bounces+graham.bloice=trihedral.com at python.org > [mailto:python-win32-bounces+graham.bloice=trihedral.com at python.org] > On Behalf Of Kurt Munson > Sent: 17 July 2012 17:08 > To: python-win32 at python.org > Subject: Re: [python-win32] new Pywin32 errors stating 'object has no > attribute' - and the code worked previously > > Graham, > > Thanks for the suggestion - deleting the \win32com\gen_py .py and .pyc files > solved the problem! > > It appears that my dispatch (whether static or dynamic) was using old > generated py instead of regenerating. Why would this be? > > Either way, deleting the folder under \win32com\gen_py solved this > problem. Thanks again for the help. > [Graham Bloice said] I don't know of a way to force regeneration, maybe the gencache module can do that, or possibly ComMakePy. From timr at probo.com Tue Jul 17 18:31:04 2012 From: timr at probo.com (Tim Roberts) Date: Tue, 17 Jul 2012 09:31:04 -0700 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <44BAEB2C477352489FFEC99834169BB3225EAE9E@nova.ncode.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> <44BAEB2C477352489FFEC99834169BB3225EAE9E@nova.ncode.com> Message-ID: <50059348.8030109@probo.com> Kurt Munson wrote: > Thanks for the suggestion - deleting the \win32com\gen_py .py and .pyc files solved the problem! No, not really. What you did was HIDE the problem. The PROBLEM is that you are simply using the wrong name for that property. The property name is "Visible" with a capital V, and it always has been. You have been relying on the case-insensitivity that dynamic dispatch provides. In my opinion, that's a dangerous practice, and your experience here shows why. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From kurt.munson at hbmncode.com Tue Jul 17 18:36:46 2012 From: kurt.munson at hbmncode.com (Kurt Munson) Date: Tue, 17 Jul 2012 17:36:46 +0100 Subject: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously In-Reply-To: <50059348.8030109@probo.com> References: <44BAEB2C477352489FFEC99834169BB3225EAE6D@nova.ncode.com> <50056FE2.1080602@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE78@nova.ncode.com> <50057625.8040101@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE88@nova.ncode.com> <500582B0.6000304@timgolden.me.uk> <44BAEB2C477352489FFEC99834169BB3225EAE95@nova.ncode.com> <44BAEB2C477352489FFEC99834169BB3225EAE9E@nova.ncode.com> <50059348.8030109@probo.com> Message-ID: <44BAEB2C477352489FFEC99834169BB3225EAEA7@nova.ncode.com> Point taken, while trying to avoid a discussion on the validity of case sensitivity. 8) -Kurt -----Original Message----- From: python-win32-bounces+kurt.munson=hbmncode.com at python.org [mailto:python-win32-bounces+kurt.munson=hbmncode.com at python.org] On Behalf Of Tim Roberts Sent: Tuesday, July 17, 2012 12:31 PM To: Python-Win32 List Subject: Re: [python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously Kurt Munson wrote: > Thanks for the suggestion - deleting the \win32com\gen_py .py and .pyc files solved the problem! No, not really. What you did was HIDE the problem. The PROBLEM is that you are simply using the wrong name for that property. The property name is "Visible" with a capital V, and it always has been. You have been relying on the case-insensitivity that dynamic dispatch provides. In my opinion, that's a dangerous practice, and your experience here shows why. -- 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 Confidentiality Notice: This email may contain confidential and/or privileged information. If you are not the intended recipient of this message, please delete it immediately and inform the sender that you have received this message in error. From ferdinandsousa at gmail.com Tue Jul 17 20:05:30 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Tue, 17 Jul 2012 23:35:30 +0530 Subject: [python-win32] py2exe issues with script using selenium Message-ID: Hi List, My environment: Win 7 Professional 64-bit, Python 2.7 64-bit and appropriate 64-bit libraries installed over that. I downloaded the 64-bit py2exe package. Though I did not specifically download the Distutils package, I guess I have it from having installed 3rd party Python libraries. I'm trying to create a py2exe executable of a script that automates Firefox using selenium webdriver. The script also uses a couple of other libraries including the python imaging library and pywin32. When I try to run the generated exe I get the following traceback: (the 1st 2 lines after the script starts are print statement output) ##------------------------------------------------------------------------------------------------------------------------------- C:\Users\ferdinand\Desktop\Landmark_Ops\dist>make_ELOG.exe Starting CLI commands CLI output parsed Traceback (most recent call last): File "make_ELOG.py", line 220, in File "selenium\webdriver\firefox\webdriver.pyc", line 51, in __init__ File "selenium\webdriver\firefox\extension_connection.pyc", line 45, in __init__ File "selenium\webdriver\firefox\firefox_profile.pyc", line 136, in add_extension File "selenium\webdriver\firefox\firefox_profile.pyc", line 289, in _install_extension File "zipfile.pyc", line 701, in __init__ IOError: [Errno 2] No such file or directory: 'C:\\Users\\ferdinand\\Desktop\\Landmark_Ops\\dist\\library.zip\\selenium\\webdriver\\firefox\\webdriver.xpi' ##------------------------------------------------------------------------------------------------------------------------------- I checked the zip folder mentioned in the path and it is missing the webdriver.xpi file. I manually added the missing file into the zip folder from a similar path in my python setup, but it still doesn't work. The start of the traceback ( line 220, in ) refers to the line where I 1st instantiate the Firefox() selenium webdriver automation object. I had earlier tried the same with pyinstaller and faced a similar kind of issue with the same webdriver.xpi file. It that case, pyinstaller used some other file format (not zip) and I was not able to edit that file. The script works quite ok in the normal python environment. Any pointers? Thanks, Ferdi -------------- next part -------------- An HTML attachment was scrubbed... URL: From janechen_1979 at yahoo.com Tue Jul 17 21:46:54 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Tue, 17 Jul 2012 12:46:54 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: References: Message-ID: <1342554414.37992.YahooMailNeo@web164004.mail.gq1.yahoo.com> Thank you for your help. However, I still got pywintypes.error: (50, "DeviceIoControl", "The request is not supported").? ?I added the following codes to?winioctlcon.py. IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL?=?CTL_CODE(?FILE_DEVICE_DISK,?0x7a0,?METHOD_BUFFERED,?FILE_ANY_ACCESS) GUID_SFF_PROTOCOL_SD = pywintypes.IID("{AD7536A8-D055-4C40-AA4D-96312DDB6B38}") I added the following codes to my script import win32con, winioctlcon """ Definition of buffer used with _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA: typedef struct _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA { USHORT Size; USHORT Reserved; GUID ProtocolGUID; } """ buf_fmt='HHs0L' buf_size=struct.calcsize(buf_fmt) hVol=win32file.CreateFile(drive,win32con.GENERIC_READ, win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL,None) ? buf=win32file.DeviceIoControl(hVol, winioctlcon.IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL,None,buf_size,None) size_SFFDISK, reserved_SFFDISK, protocolGUID_SFFDISK=struct.unpack(buf_fmt, buf)Regards, Jane---------------------------------------------------------------------- Message: 1 Date: Mon, 16 Jul 2012 21:54:03 -0400 From: "Roger Upole" To: python-win32 at python.org Subject: Re: [python-win32] Does pywin32 support SD card ??? operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? Message-ID: That one isn't in winioctlcon.py yet, but you should be able to define it relatively easily.? According to the headers: #define IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL \ ? ? ? ? ? ? CTL_CODE( FILE_DEVICE_DISK, 0x7a0, METHOD_BUFFERED, FILE_ANY_ACCESS) You'll probably need to create the output buffer yourself and initialize the Size correctly. typedef struct _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA { ? USHORT Size; ? USHORT Reserved; ? GUID? ProtocolGUID; } ? ? Roger -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jul 17 23:58:57 2012 From: timr at probo.com (Tim Roberts) Date: Tue, 17 Jul 2012 14:58:57 -0700 Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: <1342554414.37992.YahooMailNeo@web164004.mail.gq1.yahoo.com> References: <1342554414.37992.YahooMailNeo@web164004.mail.gq1.yahoo.com> Message-ID: <5005E021.4020900@probo.com> Jane Chen wrote: > > Thank you for your help. However, I still got pywintypes.error: (50, > "DeviceIoControl", "The request is not supported"). > > I added the following codes to winioctlcon.py . You should not probably modify the standard library files, because you'll lose the change when you upgrade. You should add this to your own file. > > I added the following codes to my script > import win32con, winioctlcon > """ > Definition of buffer used with _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA: > typedef struct _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA { > USHORT Size; > USHORT Reserved; > GUID ProtocolGUID; > } > """ > buf_fmt='HHs0L' > buf_size=struct.calcsize(buf_fmt) Your buf_fmt is not correct. GUID is not a string, it is a 16-byte binary GUID. You want 'HHLLLL' -- the buf_size should be 20. Plus, you really don't want "struct" to unpack the GUID. It doesn't know that type. However, that's not your fundamental problem. My guess is that you are trying to call this for an SD disk that is plugged into a USB adapter. If so, that won't work, because the operating system doesn't see it as an SD disk, it sees it as a USB disk. It has to be an SD drive connected directly to a PCI bus, and those are usually only found on laptops. The error message is exactly right -- the request is not supported. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Wed Jul 18 04:37:19 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 18 Jul 2012 12:37:19 +1000 Subject: [python-win32] py2exe issues with script using selenium In-Reply-To: References: Message-ID: <5006215F.8050108@gmail.com> The problem is a "conflict" between the firefox_profile module and py2exe. firefox_profile is attempting to open 'C:\\Users\\ferdinand\\Desktop\\Landmark_Ops\\dist\\library.zip\\selenium\\webdriver\\firefox\\webdriver.xpi' as a regular file (a .xpi file is a .zip file, hence the fact zipfile itself is throwing the error), but that file doesn't exist as a regular file. You probably need to look into the source of firefox_profile and see if you can tell it where the .xpi file lives. Then you would take advantage of py2exe's "data_files" option to arrange for the .xpi file to be packaged as a regular file, then tell firefox_profile where that location is. HTH, Mark On 18/07/2012 4:05 AM, Ferdinand Sousa wrote: > Hi List, > > My environment: Win 7 Professional 64-bit, Python 2.7 64-bit and > appropriate 64-bit libraries installed over that. > I downloaded the 64-bit py2exe package. Though I did not specifically > download the Distutils package, I guess I have it from having installed > 3rd party Python libraries. > > I'm trying to create a py2exe executable of a script that automates > Firefox using selenium webdriver. > The script also uses a couple of other libraries including the python > imaging library and pywin32. > > When I try to run the generated exe I get the following traceback: (the > 1st 2 lines after the script starts are print statement output) > > ##------------------------------------------------------------------------------------------------------------------------------- > C:\Users\ferdinand\Desktop\Landmark_Ops\dist>make_ELOG.exe > Starting CLI commands > CLI output parsed > Traceback (most recent call last): > File "make_ELOG.py", line 220, in > File "selenium\webdriver\firefox\webdriver.pyc", line 51, in __init__ > File "selenium\webdriver\firefox\extension_connection.pyc", line 45, > in __init__ > File "selenium\webdriver\firefox\firefox_profile.pyc", line 136, in > add_extension > File "selenium\webdriver\firefox\firefox_profile.pyc", line 289, in > _install_extension > File "zipfile.pyc", line 701, in __init__ > IOError: [Errno 2] No such file or directory: > 'C:\\Users\\ferdinand\\Desktop\\Landmark_Ops\\dist\\library.zip\\selenium\\webdriver\\firefox\\webdriver.xpi' > ##------------------------------------------------------------------------------------------------------------------------------- > > I checked the zip folder mentioned in the path and it is missing the > webdriver.xpi file. > I manually added the missing file into the zip folder from a similar > path in my python setup, but it still doesn't work. > The start of the traceback ( line 220, in ) refers to the line > where I 1st instantiate the Firefox() selenium webdriver automation object. > > I had earlier tried the same with pyinstaller and faced a similar kind > of issue with the same webdriver.xpi file. It that case, pyinstaller > used some other file format (not zip) and I was not able to edit that file. > > The script works quite ok in the normal python environment. > Any pointers? > > Thanks, > Ferdi > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From janechen_1979 at yahoo.com Wed Jul 18 19:37:39 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Wed, 18 Jul 2012 10:37:39 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: References: Message-ID: <1342633059.11851.YahooMailNeo@web164001.mail.gq1.yahoo.com> Jane Chen wrote: > > Thank you for your help. However, I still got pywintypes.error: (50, > "DeviceIoControl", "The request is not supported"). > >? I added the following codes to winioctlcon.py . You should not probably modify the standard library files, because you'll lose the change when you upgrade.? You should add this to your own file. > > I added the following codes to my script > import win32con, winioctlcon > """ > Definition of buffer used with _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA: > typedef struct _SFFDISK_QUERY_DEVICE_PROTOCOL_DATA { >? USHORT Size; >? USHORT Reserved; >? GUID? ProtocolGUID; > } > """ > buf_fmt='HHs0L'? > buf_size=struct.calcsize(buf_fmt) Your buf_fmt is not correct.? GUID is not a string, it is a 16-byte binary GUID.? You want 'HHLLLL' -- the buf_size should be 20.? Plus, you really don't want "struct" to unpack the GUID.? It doesn't know that type. Thank you for your help.?? Could you please help me write better codes for GUID? However, that's not your fundamental problem.? My guess is that you are trying to call this for an SD disk that is plugged into a USB adapter. If so, that won't work, because the operating system doesn't see it as an SD disk, it sees it as a USB disk.? It has to be an SD drive connected directly to a PCI bus, and those are usually only found on laptops.? The error message is exactly right -- the request is not supported. You are right. I was using USB.? Based on your suggestion, I connected the SD drive directly to a PCI bus and set buf_fmt='HHLLLL'. However, I got?another error message: (1, 'DeviceIoControl', 'Incorrect function'). I think I did not use the function correctly. Best, Jane -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 18 19:54:48 2012 From: timr at probo.com (Tim Roberts) Date: Wed, 18 Jul 2012 10:54:48 -0700 Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: <1342633059.11851.YahooMailNeo@web164001.mail.gq1.yahoo.com> References: <1342633059.11851.YahooMailNeo@web164001.mail.gq1.yahoo.com> Message-ID: <5006F868.2020905@probo.com> Jane Chen wrote: > > Thank you for your help. > Could you please help me write better codes for GUID? What are you going to do with it? You will get back a 20-byte string. The last 16-bytes are the binary GUID. The way you handle that depends on what you need to do with it. > You are right. I was using USB. > Based on your suggestion, I connected the SD drive directly to a PCI > bus and set buf_fmt='HHLLLL'. However, I got another error message: > (1, 'DeviceIoControl', 'Incorrect function'). I think I did not use > the function correctly. How are you specifying the volume? You should be using a string like "\\\\.\\E:" to open the volume for the E: drive (where the backslashes are doubled because of Python's string escaping). I get "incorrect function" if I try to use this on a standard disk drive. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From janechen_1979 at yahoo.com Wed Jul 18 21:09:10 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Wed, 18 Jul 2012 12:09:10 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: References: Message-ID: <1342638550.99455.YahooMailNeo@web164002.mail.gq1.yahoo.com> I want my script to tell if the removable disk is an SD card or not, so I wrote the following script. buf_fmt='HHLLLL' ? buf_size=struct.calcsize(buf_fmt) drives = (drive for drive in win32api.GetLogicalDriveStrings ().split ("\\\000") if drive) ? ? ? ? for drive in drives: ? ? ? ? ? ? if win32file.GetDriveType (drive)==2: ? ? ? ? ? ? ? ? print "Removable Disk" , drive ? ? ? ? ? ? ? ? if 'A' in drive: ? ? ? ? ? ? ? ? ? ? print "floppy" ? ? ? ? ? ? ? ? else: ? ? ? ? ? ? ? ? ? ? drive="\\\\.\\"+drive+'.' ? ? print drive ? ? ? ? ? ? ? ? ? ? hVol = win32file.CreateFile(drive, win32con.GENERIC_READ|win32con.GENERIC_WRITE, ? ? ? ? ? ? ? ? ? ? ? ? win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, ? ? ? ? ? ? ? ? ? ? ? ? 0, None) ? ? ? ? ? ? ? ? ? ? if hVol == win32file.INVALID_HANDLE_VALUE: ?? ? ? ? ? ? ? ? ? ? ? ? ? print "could not open device" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? buf=win32file.DeviceIoControl(hVol, winioctlcon.IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL,None,buf_size,None) ? ? ? ? ? ? ? ? ? ? size_SFFDISK, reserved_SFFDISK, protocolGUID_SFFDISK=struct.unpack(buf_fmt, buf)? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? else: ? ? ? ? ? ? ? ? print "Not a removable disk:" , drive ? ? I printed out the drive letter in the script and checked the letter with the SD card letter on win7. The letters are the same. However, as I mentioned, I get?(1, 'DeviceIoControl', 'Incorrect function'). Thank you, Jane > > Thank you for your help. > Could you please help me write better codes for GUID? What are you going to do with it? You will get back a 20-byte string. The last 16-bytes are the binary GUID. The way you handle that depends on what you need to do with it. > You are right. I was using USB. > Based on your suggestion, I connected the SD drive directly to a PCI > bus and set buf_fmt='HHLLLL'. However, I got another error message: > (1, 'DeviceIoControl', 'Incorrect function'). I think I did not use > the function correctly. How are you specifying the volume? You should be using a string like "\\\\.\\E:" to open the volume for the E: drive (where the backslashes are doubled because of Python's string escaping). I get "incorrect function" if I try to use this on a standard disk drive. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 18 21:58:17 2012 From: timr at probo.com (Tim Roberts) Date: Wed, 18 Jul 2012 12:58:17 -0700 Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: <1342638550.99455.YahooMailNeo@web164002.mail.gq1.yahoo.com> References: <1342638550.99455.YahooMailNeo@web164002.mail.gq1.yahoo.com> Message-ID: <50071559.5000001@probo.com> Jane Chen wrote: > I want my script to tell if the removable disk is an SD card or not, > so I wrote the following script. > > buf_fmt='HHLLLL' > buf_size=struct.calcsize(buf_fmt) > > drives = (drive for drive in win32api.GetLogicalDriveStrings ().split > ("\\\000") if drive) > for drive in drives: > if win32file.GetDriveType (drive)==2: > print "Removable Disk" , drive > if 'A' in drive: > print "floppy" > else: > drive="\\\\.\\"+drive+'.' Why are you adding a dot? That's a mistake. You want just "\\\\.\\E:" . Remove the +'.' -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From janechen_1979 at yahoo.com Wed Jul 18 22:47:22 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Wed, 18 Jul 2012 13:47:22 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: References: Message-ID: <1342644442.41272.YahooMailNeo@web164005.mail.gq1.yahoo.com> Sorry. It's a mistake. However, I still get the same error message. Maybe there is another mistake. :( Is there any tool for debugging purpose?? Thank you, Jane >? ? ? ? ? ? ? ? ? ? drive="\\\\.\\"+drive+'.' Why are you adding a dot?? That's a mistake.? You want? just "\\\\.\\E:" .? Remove the? +'.' -- 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 End of python-win32 Digest, Vol 112, Issue 18 ********************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Jul 19 00:08:36 2012 From: timr at probo.com (Tim Roberts) Date: Wed, 18 Jul 2012 15:08:36 -0700 Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: <1342644442.41272.YahooMailNeo@web164005.mail.gq1.yahoo.com> References: <1342644442.41272.YahooMailNeo@web164005.mail.gq1.yahoo.com> Message-ID: <500733E4.6060201@probo.com> Jane Chen wrote: > Sorry. It's a mistake. However, I still get the same error message. > Maybe there is another mistake. :( > Is there any tool for debugging purpose? What I would do is write the code as a C program just to make sure the API does what I expect. That at least eliminates the Python layers from consideration. What SD card reader are you using? Not all of the behave nicely. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From wanglei211 at mails.gucas.ac.cn Thu Jul 19 01:35:18 2012 From: wanglei211 at mails.gucas.ac.cn (=?gb2312?B?zfTA1w==?=) Date: Thu, 19 Jul 2012 07:35:18 +0800 Subject: [python-win32] python-win32 with vba Message-ID: Hi, I don't know how to handle ms word's events. By VBA, the code is as following: > Private Sub Ducoment_Open(): > my code > End Sub. The code in ms word macro is to capture the 'Open' event, when the word is opened, my code will be executed. How can I perform by python-win32. Thanks Regards. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wanglei at nelmail.iie.ac.cn Thu Jul 19 04:16:11 2012 From: wanglei at nelmail.iie.ac.cn (wanglei) Date: Thu, 19 Jul 2012 10:16:11 +0800 Subject: [python-win32] How to insert macro into ms word by using python? Message-ID: <201207191016105453881@nelmail.iie.ac.cn> Hello, I have some problem with pywin32com programming in ms word? I have a macro code, but my program language is python-extension, I want to insert the macro into ms word? And the word object is created by pywin32com, like docApp = win32com.client.Dispatch('Word.Application') doc = docApp.Documents.Add(). Do you give me any ideas? Thanks very much. Regards. Wang Lei, Information Security Research Center, Institute Of Information Engineering, Chinese Academy Of Sciences. Phone Number:010-82546727. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jul 20 19:24:22 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 20 Jul 2012 10:24:22 -0700 Subject: [python-win32] How to insert macro into ms word by using python? In-Reply-To: <201207191016105453881@nelmail.iie.ac.cn> References: <201207191016105453881@nelmail.iie.ac.cn> Message-ID: <50099446.6020109@probo.com> wanglei wrote: > Hello, I have some problem with pywin32com programming in ms word? I > have a macro code, but my program language is python-extension, I want > to insert the macro into ms word? > And the word object is created by pywin32com, like docApp = > win32com.client.Dispatch('Word.Application') doc = > docApp.Documents.Add(). What do you mean by "insert the macro"? The word "macro" really doesn't have much meaning in Word any more. Word allows you to record macros as Visual Basic code, but when you play it back, you are really just running a VB function. So, if you have a bunch of VB code that was recorded as a macro, you can rewrite that code into Python and insert that in your Python module. If that's not what you mean, perhaps you can provide a more complete example to help me understand. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jul 20 19:43:35 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 20 Jul 2012 10:43:35 -0700 Subject: [python-win32] python-win32 with vba In-Reply-To: References: Message-ID: <500998C7.4080800@probo.com> ?? wrote: > Hi, I don't know how to handle ms word's events. > By VBA, the code is as following: > > > Private Sub Ducoment_Open(): > > my code > > End Sub. > > The code in ms word macro is to capture the 'Open' event, when the word > is opened, my code will be executed. How can I perform by python-win32. First, I want to make sure you understand the limitations. If your Python code has launched the Word.Application as a COM server, then you can certainly handle events for that instance. But you cannot handle all Word events everywhere. For example, if some user just starts Word and opens a Word document, you can't catch that, because your Python process is not running. So, with that, here's an example that handles the DocumentOpen event from Word. Note that you'll be handling events from the Word Application object ("DocumentOpen" is an Application event). Your VBA code above is handling the "Open" event on the "Document" object. That's harder to do on Python. import win32com.client class myHandler(object): def __init__(self): print "__init__" def OnDocumentOpen(self,doc): print "Got document!" print doc ob = win32com.client.DispatchWithEvents("Word.Application", myHandler) ob.Visible = True ob.Documents.Open("c:/tmp/xxx.doc") ob.Application.Quit() -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From michael.k.fox at boeing.com Sat Jul 21 05:55:12 2012 From: michael.k.fox at boeing.com (Fox, Michael K) Date: Fri, 20 Jul 2012 20:55:12 -0700 Subject: [python-win32] Need data type identifiers Message-ID: We are having occasional difficulties when we need to pass an argument in-and-out of a COM method that we are calling in Python. There is some magic in makepy that normally handles this for us but occasionally it fails because it somehow reads the typelib incorrectly and misunderstands the data type it must create. Specifically, I have a C++ method exposed to COM and it expects an empty SafeArray of two elements (double floats) to be passed as an argument. That method revises the array, filling it with two values. We have found that makepy assigns some sort of identifier to each data type. For instance an array of strings is assigned (24584, 3) and an array of variants is assigned (24588, 3) as shown in the line of code below, taken from one of the wrappers created by Makepy. def GetDirection(self, oDirection=(0,0)): return self._ApplyTypes_(1611137025, 1, (24, 0), ((24588,3),), u'GetDirection', None, oDirection) Occasionally pywin32 assigns the wrong identifier then the argument is cast as the wrong data type and an error is thrown. We stumbled upon the correct identifier and when we corrected the identifier assigned by Makepy then we were able to call the method without throwing an error. Where can we find a list of these identifiers? Mike Fox -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Sat Jul 21 12:38:23 2012 From: rupole at hotmail.com (Roger Upole) Date: Sat, 21 Jul 2012 06:38:23 -0400 Subject: [python-win32] Need data type identifiers References: Message-ID: The first number is a combination of VARENUM values (pythoncom.VT_*) indicating the type, and the second is from PARAMFLAGS (pythoncom.PARAMFLAG_*). (24584, 3) is (VT_ARRAY|VT_BYREF|VT_BSTR, PARAMFLAG_FIN|PARAMFLAG_FOUT) (24588, 3) is (VT_ARRAY|VT_BYREF|VT_VARIANT, PARAMFLAG_FIN|PARAMFLAG_FOUT) If the types generated by makepy are not what the methods are expecting, most likely they're actually specified incorrectly in the application's typelib. Roger From graham.bloice at trihedral.com Mon Jul 23 09:47:24 2012 From: graham.bloice at trihedral.com (Graham Bloice) Date: Mon, 23 Jul 2012 08:47:24 +0100 Subject: [python-win32] Need data type identifiers In-Reply-To: References: Message-ID: This issue sometimes occurs when the typelib specifies a VARIANT type argument, implying that any VARIANT type will do, but the COM server is coded to expect an actual type and does not (incorrectly IMHO) attempt to convert the incoming VARIANT to the appropriate type. Makepy has no idea of what type is really expected so I think converts the parameter based on the Python type of the value passed in the call. This may or may not line up with what the COM Server is expecting. When this occurs, and you don?t have access to the COM Server code to fix it, you must force the COM Client to pass the appropriate types. ?Adjusting? the makepy generated file is one way of doing this. *From:* python-win32-bounces+graham.bloice=trihedral.com at python.org [mailto: python-win32-bounces+graham.bloice=trihedral.com at python.org] *On Behalf Of *Fox, Michael K *Sent:* 21 July 2012 04:55 *To:* python-win32 at python.org *Subject:* [python-win32] Need data type identifiers We are having occasional difficulties when we need to pass an argument in-and-out of a COM method that we are calling in Python. There is some magic in makepy that normally handles this for us but occasionally it fails because it somehow reads the typelib incorrectly and misunderstands the data type it must create. Specifically, I have a C++ method exposed to COM and it expects an empty SafeArray of two elements (double floats) to be passed as an argument. That method revises the array, filling it with two values. We have found that makepy assigns some sort of identifier to each data type. For instance an array of strings is assigned (24584, 3) and an array of variants is assigned (24588, 3) as shown in the line of code below, taken from one of the wrappers created by Makepy. def *GetDirection*(*self*, oDirection=(0,0)): return *self*._ApplyTypes_(1611137025, 1, (24, 0), ((24588,3),), u*'GetDirection'*, None, oDirection) Occasionally pywin32 assigns the wrong identifier then the argument is cast as the wrong data type and an error is thrown. We stumbled upon the correct identifier and when we corrected the identifier assigned by Makepy then we were able to call the method without throwing an error. Where can we find a list of these identifiers? *Mike Fox* -------------- next part -------------- An HTML attachment was scrubbed... URL: From ferdinandsousa at gmail.com Mon Jul 23 17:21:57 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Mon, 23 Jul 2012 20:51:57 +0530 Subject: [python-win32] py2exe issues with script using selenium In-Reply-To: <5006215F.8050108@gmail.com> References: <5006215F.8050108@gmail.com> Message-ID: Hi Mark, I tried extracting the files inside webdriver.xpi into a folder webdriverxpi and placed it in lieu of the former in the zip file. I had to tweak some code inside the firefox_profile.py file as well, so that it would add the files inside the webdriverxpi folder to the current path environment. Some thing like: ## --------------------------------------------------------------------------------------------- WEBDRIVER_EXT = "webdriver.xpi" ## changed this to "webdriverxpi" ..... later in the code .... if addon == WEBDRIVER_EXT: addon = os.path.join(os.path.dirname(__file__), WEBDRIVER_EXT) ## --------------------------------------------------------------------------------------------- It worked. As in, it now no longer gave the error I was getting initially. But, I faced some other issue with some xml standard lib being included elsewhere in the selenium include tree (IIRC it was Lib\xml\dom\minidom.py). The issue was similar to that faced earlier, missing file. Rather than have to handle every subsequent import issue, I decided to try a different approach. I ran py2exe with the --skip-archive option, placed the compressed webdriver.xpi file into the correct location and voila! Thanks a ton for your help. What would I have done without you guys?! :-D Ferdi PS: Maybe py2exe should include files it does not recognize as is in the include tree?? Just my 2 cents. On Wed, Jul 18, 2012 at 8:07 AM, Mark Hammond wrote: > The problem is a "conflict" between the firefox_profile module and py2exe. > firefox_profile is attempting to open 'C:\\Users\\ferdinand\\** > Desktop\\Landmark_Ops\\dist\\**library.zip\\selenium\\** > webdriver\\firefox\\webdriver.**xpi' as a regular file (a .xpi file is a > .zip file, hence the fact zipfile itself is throwing the error), but that > file doesn't exist as a regular file. > > You probably need to look into the source of firefox_profile and see if > you can tell it where the .xpi file lives. Then you would take advantage > of py2exe's "data_files" option to arrange for the .xpi file to be packaged > as a regular file, then tell firefox_profile where that location is. > > HTH, > > Mark > > > On 18/07/2012 4:05 AM, Ferdinand Sousa wrote: > >> Hi List, >> >> My environment: Win 7 Professional 64-bit, Python 2.7 64-bit and >> appropriate 64-bit libraries installed over that. >> I downloaded the 64-bit py2exe package. Though I did not specifically >> download the Distutils package, I guess I have it from having installed >> 3rd party Python libraries. >> >> I'm trying to create a py2exe executable of a script that automates >> Firefox using selenium webdriver. >> The script also uses a couple of other libraries including the python >> imaging library and pywin32. >> >> When I try to run the generated exe I get the following traceback: (the >> 1st 2 lines after the script starts are print statement output) >> >> ##----------------------------**------------------------------** >> ------------------------------**------------------------------**--------- >> C:\Users\ferdinand\Desktop\**Landmark_Ops\dist>make_ELOG.**exe >> Starting CLI commands >> CLI output parsed >> Traceback (most recent call last): >> File "make_ELOG.py", line 220, in >> File "selenium\webdriver\firefox\**webdriver.pyc", line 51, in >> __init__ >> File "selenium\webdriver\firefox\**extension_connection.pyc", line 45, >> in __init__ >> File "selenium\webdriver\firefox\**firefox_profile.pyc", line 136, in >> add_extension >> File "selenium\webdriver\firefox\**firefox_profile.pyc", line 289, in >> _install_extension >> File "zipfile.pyc", line 701, in __init__ >> IOError: [Errno 2] No such file or directory: >> 'C:\\Users\\ferdinand\\**Desktop\\Landmark_Ops\\dist\\** >> library.zip\\selenium\\**webdriver\\firefox\\webdriver.**xpi' >> ##----------------------------**------------------------------** >> ------------------------------**------------------------------**--------- >> >> I checked the zip folder mentioned in the path and it is missing the >> webdriver.xpi file. >> I manually added the missing file into the zip folder from a similar >> path in my python setup, but it still doesn't work. >> The start of the traceback ( line 220, in ) refers to the line >> where I 1st instantiate the Firefox() selenium webdriver automation >> object. >> >> I had earlier tried the same with pyinstaller and faced a similar kind >> of issue with the same webdriver.xpi file. It that case, pyinstaller >> used some other file format (not zip) and I was not able to edit that >> file. >> >> The script works quite ok in the normal python environment. >> Any pointers? >> >> Thanks, >> Ferdi >> >> >> ______________________________**_________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/**mailman/listinfo/python-win32 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From janechen_1979 at yahoo.com Mon Jul 23 20:20:10 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Mon, 23 Jul 2012 11:20:10 -0700 (PDT) Subject: [python-win32] python-win32 Digest, Vol 112, Issue 19 In-Reply-To: References: Message-ID: <1343067610.86884.YahooMailNeo@web164001.mail.gq1.yahoo.com> Thank you for your help! No luck so far. I wrote a C program and got the same results as python: Win 7 Notebook (with SD card inserted?directly i.e. no SD card reader)?Error code: 1 Win 7 Notebook (without SD card inserted?at all)?Error code: 6 WinXP desktop (with USB stick but?without SD card inserted?at all)?Error code: 50 int main(int argc, char* argv[]) { ?string sdrive("\\\\.\\e:");? ? ?HANDLE hcd = CreateFile(sdrive.c_str(),? ? GENERIC_READ,? ? FILE_SHARE_READ|FILE_SHARE_WRITE, ? NULL,? ? OPEN_EXISTING,? ? FILE_ATTRIBUTE_READONLY,? ? NULL); ? ?if (hcd == INVALID_HANDLE_VALUE) ? printf("Could not open drive\\\n"); ?else ? printf ("%s \n", "opened drive"); ? ?DWORD d = 0; ?int nSizeOfCmd = sizeof(SFFDISK_QUERY_DEVICE_PROTOCOL_DATA) ; ?SFFDISK_QUERY_DEVICE_PROTOCOL_DATA *pCmdBuf = (SFFDISK_QUERY_DEVICE_PROTOCOL_DATA*) new BYTE[nSizeOfCmd]; ?memset(pCmdBuf, 0, nSizeOfCmd); ? ?BOOL bResult=DeviceIoControl(hcd, IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL, NULL, 0,? ?pCmdBuf, nSizeOfCmd, &d, NULL); ?DWORD dwErr = GetLastError(); ?CloseHandle(hcd); ?if(!bResult){ ? ? ? printf("Failed to get ProtocolGUID, err code: %d",dwErr); ? ? ?? ?} ?else{ ?printf("%s \n", pCmdBuf->ProtocolGUID); ?} ? ?delete [] pCmdBuf; ?return 0; ? } Thank you, Jane Jane Chen wrote: > Sorry. It's a mistake. However, I still get the same error message. > Maybe there is another mistake. :( > Is there any tool for debugging purpose? What I would do is write the code as a C program just to make sure the API does what I expect.? That at least eliminates the Python layers from consideration. What SD card reader are you using?? Not all of the behave nicely. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. - -------------- next part -------------- An HTML attachment was scrubbed... URL: From janechen_1979 at yahoo.com Mon Jul 23 20:49:46 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Mon, 23 Jul 2012 11:49:46 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: <1343067610.86884.YahooMailNeo@web164001.mail.gq1.yahoo.com> References: <1343067610.86884.YahooMailNeo@web164001.mail.gq1.yahoo.com> Message-ID: <1343069386.67163.YahooMailNeo@web164003.mail.gq1.yahoo.com> Sorry! I forgot to change the subject in the previous email. Thank you for your help! No luck so far. I wrote a C program and got the same results as python: Win 7 Notebook (with SD card inserted?directly i.e. no SD card reader)?Error code: 1 Win 7 Notebook (without SD card inserted?at all)?Error code: 6 WinXP desktop (with USB stick but?without SD card inserted?at all)?Error code: 50 int main(int argc, char* argv[]) { ?string sdrive("\\\\.\\e:");? ? ?HANDLE hcd = CreateFile(sdrive.c_str(),? ? GENERIC_READ,? ? FILE_SHARE_READ|FILE_SHARE_WRITE, ? NULL,? ? OPEN_EXISTING,? ? FILE_ATTRIBUTE_READONLY,? ? NULL); ? ?if (hcd == INVALID_HANDLE_VALUE) ? printf("Could not open drive\\\n"); ?else ? printf ("%s \n", "opened drive"); ? ?DWORD d = 0; ?int nSizeOfCmd = sizeof(SFFDISK_QUERY_DEVICE_PROTOCOL_DATA) ; ?SFFDISK_QUERY_DEVICE_PROTOCOL_DATA *pCmdBuf = (SFFDISK_QUERY_DEVICE_PROTOCOL_DATA*) new BYTE[nSizeOfCmd]; ?memset(pCmdBuf, 0, nSizeOfCmd); ? ?BOOL bResult=DeviceIoControl(hcd, IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL, NULL, 0,? ?pCmdBuf, nSizeOfCmd, &d, NULL); ?DWORD dwErr = GetLastError(); ?CloseHandle(hcd); ?if(!bResult){ ? ? ? printf("Failed to get ProtocolGUID, err code: %d",dwErr); ? ? ?? ?} ?else{ ?printf("%s \n", pCmdBuf->ProtocolGUID); ?} ? ?delete [] pCmdBuf; ?return 0; ? } Thank you, Jane Jane Chen wrote: > Sorry. It's a mistake. However, I still get the same error message. > Maybe there is another mistake. :( > Is there any tool for debugging purpose? What I would do is write the code as a C program just to make sure the API does what I expect.? That at least eliminates the Python layers from consideration. What SD card reader are you using?? Not all of the behave nicely. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. - -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jul 23 21:08:56 2012 From: timr at probo.com (Tim Roberts) Date: Mon, 23 Jul 2012 12:08:56 -0700 Subject: [python-win32] Need data type identifiers In-Reply-To: References: Message-ID: <500DA148.90307@probo.com> Fox, Michael K wrote: > > ... > > > > def*GetDirection*(/self/, oDirection=(0,0)): > > return/self/._ApplyTypes_(1611137025, 1, (24, 0), > ((24588,3),), u/'GetDirection'/, None, oDirection) > > > > Occasionally pywin32 assigns the wrong identifier then the argument is > cast as the wrong data type and an error is thrown. We stumbled upon > the correct identifier and when we corrected the identifier assigned > by Makepy then we were able to call the method without throwing an > error. Where can we find a list of these identifiers? > Some day, I will write this down instead of having to go look for it every time. The master reference for this information is the include file which is part of the Windows SDK. That has a very short explanation of each type, plus the numeric value. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Jul 23 21:17:17 2012 From: timr at probo.com (Tim Roberts) Date: Mon, 23 Jul 2012 12:17:17 -0700 Subject: [python-win32] python-win32 Digest, Vol 112, Issue 19 In-Reply-To: <1343067610.86884.YahooMailNeo@web164001.mail.gq1.yahoo.com> References: <1343067610.86884.YahooMailNeo@web164001.mail.gq1.yahoo.com> Message-ID: <500DA33D.90401@probo.com> Jane Chen wrote: > Thank you for your help! No luck so far. > > I wrote a C program and got the same results as python: Support for this ioctl is sporadic. It may simply be that your SD drive doesn't support it. > Win 7 Notebook (with SD card inserted directly i.e. no SD card > reader) Error code: 1 ERROR_INVALID_FUNCTION. There has to be an SD card reader somewhere. > Win 7 Notebook (without SD card inserted at all) Error code: 6 ERROR_INVALID_HANDLE > WinXP desktop (with USB stick but without SD card inserted at > all) Error code: 50 ERROR_FILE_EXISTS? Remember that a USB stick will never support this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Tue Jul 24 04:09:05 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 24 Jul 2012 12:09:05 +1000 Subject: [python-win32] Need data type identifiers In-Reply-To: References: Message-ID: <500E03C1.4010706@gmail.com> All the other comments in this thread are correct, but one other thing you can do in recent pywin32 builds is to use win32com.client.VARIANT to override how a value is passed - search for 'win32com.client.VARIANT' in pywin32.chm for basic docs. HTH, Mark On 21/07/2012 1:55 PM, Fox, Michael K wrote: > We are having occasional difficulties when we need to pass an argument > in-and-out of a COM method that we are calling in Python. There is some > magic in makepy that normally handles this for us but occasionally it > fails because it somehow reads the typelib incorrectly and > misunderstands the data type it must create. Specifically, I have a C++ > method exposed to COM and it expects an empty SafeArray of two elements > (double floats) to be passed as an argument. That method revises the > array, filling it with two values. We have found that makepy assigns > some sort of identifier to each data type. For instance an array of > strings is assigned (24584, 3)and an array of variants is assigned > (24588, 3) as shown in the line of code below, taken from one of the > wrappers created by Makepy. > > def*GetDirection*(/self/, oDirection=(0,0)): > > return/self/._ApplyTypes_(1611137025, 1, (24, 0), ((24588,3),), > u/'GetDirection'/, None, oDirection) > > Occasionally pywin32 assigns the wrong identifier then the argument is > cast as the wrong data type and an error is thrown. We stumbled upon > the correct identifier and when we corrected the identifier assigned by > Makepy then we were able to call the method without throwing an error. > Where can we find a list of these identifiers? > > *Mike Fox* > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From raf at raf.org Wed Jul 25 08:00:33 2012 From: raf at raf.org (raf at raf.org) Date: Wed, 25 Jul 2012 16:00:33 +1000 Subject: [python-win32] time/datetime module wierdness on some windows7/XP PCs In-Reply-To: <20120723063647.GA29042@raf.org> References: <20120723063647.GA29042@raf.org> Message-ID: <20120725060033.GA28747@raf.org> hi, i've just noticed the following wierdness with the time and datetime modules (python-2.6.2 and python-2.7.3) on three windows7 hosts and one windowsxp host (but not another xp host) and i'm wondering if anyone else has encountered this and knows how to fix it. the first problem is that time.timezone contains 0 instead of the usual -36000 (for Australia/Sydney). the second problem is that time.localtime(...).is_dst is wrong. time.tzname is also wrong but i care less about that. the demonstration code and output is below. i can fake the time.timezone being absent but i can't see any good way to deal with localtime not knowing when it's daylight savings. it appears to think it's DST when it isn't and vice versa. this all worked before the upgrades to the new windows7 hosts. the xp host that also exhibits the problem has recently had its PSU, MB, CPU and RAM replaced but the HDD remains the same. the xp host that doesn't exhibit the problem has all old hardware. so the common factor seems to be new hardware rather than specifically windows7. the third problem is that datetime.datetime.now() (and time.strftime() and time.localtime() and presumably time.time()) don't always return the current time. sometimes they do. sometimes the "current time" jumps back usually 9 hours for a while and then returns to normal. note that the current time that windows displays to the user is always correct. it's just python's idea of the current time that is wrong. all hosts have the correct timezone (i.e. Australia/Sydney or rather "(GMT +10:00) Canberra, Melbourne, Sydney" with automatic DST adjustment) and automatic time synchronisation. all hosts have the hardware clock in the local timezone and windows doesn't have the RealTimeIsUniversal=1 registry entry so it knows that the hardware clock is in the local timezone. so there's no confusion there. any help would be appreciated. cheers, raf #!/usr/bin/env python import time print('time.timezone = %r (should be -36000)' % time.timezone) print('time.tzname = %r (should be (\'EST\', \'EST\' or similar))' % (time.tzname,)) print('dst in june = %r (should be 0 (for Australia/Sydney))' % time.localtime(time.mktime((2012, 6, 1, 0, 0, 0, 0, 0, -1))).tm_isdst) print('dst in december = %r (should be 1 (for Australia/Sydney))' % time.localtime(time.mktime((2012, 12, 1, 0, 0, 0, 0, 0, -1))).tm_isdst) # Max OS X 10.6.8 (correct) # time.timezone = -36000 (should be -36000) # time.tzname = ('EST', 'EST') (should be ('EST', 'EST') or similar) # dst in june = 0 (should be 0 (for Australia/Sydney)) # dst in december = 1 (should be 1 (for Australia/Sydney)) # debian-6.0 (correct) # time.timezone = -36000 (should be -36000) # time.tzname = ('EST', 'EST') (should be ('EST', 'EST') or similar) # dst in june = 0 (should be 0 (for Australia/Sydney)) # dst in december = 1 (should be 1 (for Australia/Sydney)) # Windows XP Professional Service Pack 3 (correct) # time.timezone = -36000 (should be -36000) # time.tzname = ('AUS Eastern Standard Time', 'AUS Eastern Daylight Time') (should be ('EST', 'EST') or similar) # dst in june = 0 (should be 0 (for Australia/Sydney)) # dst in december = 1 (should be 1 (for Australia/Sydney)) # Windows 7 and Windows XP Professional Service Pack 3 (incorrect) # time.timezone = 0 (should be -36000) # time.tzname = ('Aus', 'tra') (should be ('EST', 'EST') or similar) # dst in june = 1 (should be 0 (for Australia/Sydney)) # dst in december = 0 (should be 1 (for Australia/Sydney)) From cjfd48 at hotmail.com Wed Jul 25 19:23:36 2012 From: cjfd48 at hotmail.com (Carlos Hotmail) Date: Wed, 25 Jul 2012 12:23:36 -0500 Subject: [python-win32] Python WMI SCript to get installed software Message-ID: Hi all on the list. The following question is regarding an error that raises when i try to execute this script: import _winreg import wmi r = wmi.Registry () result, names = r.EnumKey ( hDefKey=_winreg.HKEY_LOCAL_MACHINE, sSubKeyName="Software" ) for key in names: print key and this is the error message it give me: Traceback (most recent call last): File "C:\Python27\wmitest8.py", line 7, in sSubKeyName="Software" File "C:\Python27\lib\site-packages\wmi.py", line 431, in __call__ handle_com_error () File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error raise klass (com_error=err) x_wmi: I?m on a win7 machine, python 2.7 installed, and win32 library installed. what i?m trying to do is to get the installed software on the machine, but not with the Win32_Product, because the list it posts seems incomplete, not all the installed software is on that list. Thanks in advance for the help you can privide me. Carlos Fuentes -------------- next part -------------- An HTML attachment was scrubbed... URL: From saunders.m3 at we-learn.com Wed Jul 25 19:51:38 2012 From: saunders.m3 at we-learn.com (M Saunders TAS) Date: Wed, 25 Jul 2012 18:51:38 +0100 Subject: [python-win32] Python WMI SCript to get installed software In-Reply-To: References: Message-ID: <3A8573B667AAE24D810B12B0ECDEB0B101501046B7CF@EXVS-1.WARWICK.welearn.internal> >From http://msdn.microsoft.com/en-us/library/windows/desktop/aa394378%28v=vs.85%29.aspx Win32_Product only lists software installed by Windows Installer (applications installed via msi or msp packages) Parsing the registry key "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" should lead to information regarding other installed software. Matt --------------------------------------------------------------------------------------------- Subject: [python-win32] Python WMI SCript to get installed software Hi all on the list. The following question is regarding an error that raises when i try to execute this script: import _winreg import wmi r = wmi.Registry () result, names = r.EnumKey ( hDefKey=_winreg.HKEY_LOCAL_MACHINE, sSubKeyName="Software" ) for key in names: print key and this is the error message it give me: Traceback (most recent call last): File "C:\Python27\wmitest8.py", line 7, in sSubKeyName="Software" File "C:\Python27\lib\site-packages\wmi.py", line 431, in __call__ handle_com_error () File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error raise klass (com_error=err) x_wmi: I?m on a win7 machine, python 2.7 installed, and win32 library installed. what i?m trying to do is to get the installed software on the machine, but not with the Win32_Product, because the list it posts seems incomplete, not all the installed software is on that list. Thanks in advance for the help you can privide me. Carlos Fuentes Warwickshire Schools Email System This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please forward to: postmaster at we-learn.com. If the content of this email is considered to be inappropriate or offensive please report by forwarding to: reportabuse at we-learn.com From timr at probo.com Wed Jul 25 20:41:27 2012 From: timr at probo.com (Tim Roberts) Date: Wed, 25 Jul 2012 11:41:27 -0700 Subject: [python-win32] Python WMI SCript to get installed software In-Reply-To: References: Message-ID: <50103DD7.8020304@probo.com> Carlos Hotmail wrote: > Hi all on the list. > > The following question is regarding an error that raises when i try to > execute this script: > import _winreg > import wmi > > r = wmi.Registry () > result, names = r.EnumKey ( > hDefKey=_winreg.HKEY_LOCAL_MACHINE, > sSubKeyName="Software" > ) > for key in names: > print key > ... > and this is the error message it give me: > x_wmi: excepci\xf3n.', (0, u'SWbemProperty', u'Los tipos no coinciden ', > None, 0, -2147217403), None)> Is that EXACTLY your code? Because I typed that code into my XP machine exactly as you have it, and it worked just fine. -2147217403 is 0x80041005, which is WBEM_E_TYPE_MISMATCH (which is probably what "Los tipos no coinciden" means..). > what i?m trying to do is to get the installed software on the machine, > but not with the Win32_Product, because the list it posts seems > incomplete, not all the installed software is on that list. The Software key of the registry is not the right way to do that. Firstly, that usually has company names, not product names. Secondly, it's entirely up to the app whether they need a registry key or not. Some do, some don't. In actual fact, there simply is no central repository of installed software on a Windows machine. You can go enumerate the uninstall list, but that only works if the application created an uninstaller. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Wed Jul 25 21:14:03 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 25 Jul 2012 20:14:03 +0100 Subject: [python-win32] Python WMI SCript to get installed software In-Reply-To: References: Message-ID: <5010457B.8080602@timgolden.me.uk> On 25/07/2012 18:23, Carlos Hotmail wrote: > Hi all on the list. > > The following question is regarding an error that raises when i try to execute this script: > import _winreg > import wmi > > r = wmi.Registry () > result, names = r.EnumKey ( > hDefKey=_winreg.HKEY_LOCAL_MACHINE, > sSubKeyName="Software" > ) > for key in names: > print key and this is the error message it give me: > > Traceback (most recent call last): > File "C:\Python27\wmitest8.py", line 7, in > sSubKeyName="Software" > File "C:\Python27\lib\site-packages\wmi.py", line 431, in __call__ > handle_com_error () > File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error > raise klass (com_error=err) > x_wmi: I can't see any issue on Win7 Python 2.7 If you still can't get it to work, could you produce a dump of the interpreter session in case something's getting lost in translation? TJG From vernondcole at gmail.com Thu Jul 26 07:50:51 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 25 Jul 2012 23:50:51 -0600 Subject: [python-win32] time/datetime module wierdness on some windows7/XP PCs In-Reply-To: <20120725060033.GA28747@raf.org> References: <20120723063647.GA29042@raf.org> <20120725060033.GA28747@raf.org> Message-ID: Dear raf: Yes, time zones in the python time module are known to be somewhat messed up. Mark Hammond and I went several rounds while trying to create a test for the "python time" capabilities in adodbapi. When a test worked for me in North America, it was almost guaranteed to fail for him in antipodes. The problems seem to be deep in the standard library code. We finally concluded that we would just document the problems with "time" and suggest that everyone use "datetime", which is considerably more capable. Time zone aware datetime objects seemed to work perfectly. (Are you _sure_ that datetime.datetime.now() was messing up in your situation?) Jason Coombs contributed the "win32timezone" module to pywin32 which makes use of the extensive time zone support in the Windows registry. Look it up in your pywin32 documentation. You might be especially interested in win32timezone.now(). If I understand what you are looking for, the return value of win32api.GetTimeZoneInformation() might give you the correct answer. So, in answer to your question "how to fix it", I would suggest that you start with: >>>import win32timezone, datetime Please report back if that does not work. -- Vernon Cole On Wed, Jul 25, 2012 at 12:00 AM, wrote: > hi, > > i've just noticed the following wierdness with the time and datetime > modules > (python-2.6.2 and python-2.7.3) on three windows7 hosts and one windowsxp > host (but not another xp host) and i'm wondering if anyone else has > encountered this and knows how to fix it. > > the first problem is that time.timezone contains 0 instead of > the usual -36000 (for Australia/Sydney). > > the second problem is that time.localtime(...).is_dst is wrong. > time.tzname is also wrong but i care less about that. > > the demonstration code and output is below. i can fake the > time.timezone being absent but i can't see any good way to > deal with localtime not knowing when it's daylight savings. > it appears to think it's DST when it isn't and vice versa. > > this all worked before the upgrades to the new windows7 hosts. > the xp host that also exhibits the problem has recently had > its PSU, MB, CPU and RAM replaced but the HDD remains the same. > the xp host that doesn't exhibit the problem has all old hardware. > so the common factor seems to be new hardware rather than > specifically windows7. > > the third problem is that datetime.datetime.now() (and time.strftime() and > time.localtime() and presumably time.time()) don't always return the > current time. sometimes they do. sometimes the "current time" jumps back > usually 9 hours for a while and then returns to normal. note that the > current time that windows displays to the user is always correct. it's just > python's idea of the current time that is wrong. > > all hosts have the correct timezone (i.e. Australia/Sydney or rather > "(GMT +10:00) Canberra, Melbourne, Sydney" with automatic DST adjustment) > and automatic time synchronisation. > > all hosts have the hardware clock in the local timezone and windows > doesn't have the RealTimeIsUniversal=1 registry entry so it knows > that the hardware clock is in the local timezone. so there's no > confusion there. > > any help would be appreciated. > > cheers, > raf > > #!/usr/bin/env python > import time > print('time.timezone = %r (should be -36000)' % time.timezone) > print('time.tzname = %r (should be (\'EST\', \'EST\' or similar))' % > (time.tzname,)) > print('dst in june = %r (should be 0 (for Australia/Sydney))' % > time.localtime(time.mktime((2012, 6, 1, 0, 0, 0, 0, 0, -1))).tm_isdst) > print('dst in december = %r (should be 1 (for Australia/Sydney))' % > time.localtime(time.mktime((2012, 12, 1, 0, 0, 0, 0, 0, -1))).tm_isdst) > > # Max OS X 10.6.8 (correct) > # time.timezone = -36000 (should be -36000) > # time.tzname = ('EST', 'EST') (should be ('EST', 'EST') or similar) > # dst in june = 0 (should be 0 (for Australia/Sydney)) > # dst in december = 1 (should be 1 (for Australia/Sydney)) > > # debian-6.0 (correct) > # time.timezone = -36000 (should be -36000) > # time.tzname = ('EST', 'EST') (should be ('EST', 'EST') or similar) > # dst in june = 0 (should be 0 (for Australia/Sydney)) > # dst in december = 1 (should be 1 (for Australia/Sydney)) > > # Windows XP Professional Service Pack 3 (correct) > # time.timezone = -36000 (should be -36000) > # time.tzname = ('AUS Eastern Standard Time', 'AUS Eastern Daylight Time') > (should be ('EST', 'EST') or similar) > # dst in june = 0 (should be 0 (for Australia/Sydney)) > # dst in december = 1 (should be 1 (for Australia/Sydney)) > > # Windows 7 and Windows XP Professional Service Pack 3 (incorrect) > # time.timezone = 0 (should be -36000) > # time.tzname = ('Aus', 'tra') (should be ('EST', 'EST') or similar) > # dst in june = 1 (should be 0 (for Australia/Sydney)) > # dst in december = 0 (should be 1 (for Australia/Sydney)) > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raf at raf.org Thu Jul 26 12:15:36 2012 From: raf at raf.org (raf) Date: Thu, 26 Jul 2012 20:15:36 +1000 Subject: [python-win32] time/datetime module wierdness on some windows7/XP PCs In-Reply-To: References: <20120723063647.GA29042@raf.org> <20120725060033.GA28747@raf.org> Message-ID: <20120726101535.GA15398@raf.org> Vernon Cole wrote: > Dear raf: > Yes, time zones in the python time module are known to be somewhat messed > up. Mark Hammond and I went several rounds while trying to create a test > for the "python time" capabilities in adodbapi. When a test worked for me > in North America, it was almost guaranteed to fail for him in antipodes. that's sad :-( time.localtime() should effectively just be a tiny wrapper around the standard C library function, localtime(), and my demonstration code works fine for everyone else but me so i don't think this is a problem with python's time module or the standard C library. it's more likely to be some wierdness with these windows hosts in particular. or cosmic rays. or higgs bosons. :-) > The problems seem to be deep in the standard library code. We finally > concluded that we would just document the problems with "time" and suggest > that everyone use "datetime", which is considerably more capable. Time zone > aware datetime objects seemed to work perfectly. (Are you _sure_ that > datetime.datetime.now() was messing up in your situation?) yes, i'm sure. that's how i noticed these issues in the first place. logfiles with timestamps jumping backwards and forwards many hours several times a day. the timestamps came from datetime.datetime.now().isoformat('T'). > Jason Coombs contributed the "win32timezone" module to pywin32 which makes > use of the extensive time zone support in the Windows registry. Look it > up in your pywin32 documentation. You might be especially interested in > win32timezone.now(). If I understand what you are looking for, the return > value of win32api.GetTimeZoneInformation() might give you the correct > answer. > > So, in answer to your question "how to fix it", I would suggest that you > start with: > >>>import win32timezone, datetime > > Please report back if that does not work. > -- > Vernon Cole the following code: #!/usr/bin/env python import win32api, win32con, win32timezone, datetime, time print('GetTimeZoneInformation = %r' % (win32api.GetTimeZoneInformation(),)) print('TIME_ZONE_ID_STANDARD = %r' % win32con.TIME_ZONE_ID_STANDARD) print('TIME_ZONE_ID_DAYLIGHT = %r' % win32con.TIME_ZONE_ID_DAYLIGHT) print('TIME_ZONE_ID_UNKNOWN = %r' % win32con.TIME_ZONE_ID_UNKNOWN) print('win32timezone.now = %r' % win32timezone.now()) print('datetime.now = %r' % datetime.datetime.now()) print('localtime = %r' % time.localtime()) produces: GetTimeZoneInformation = (1, (-600, u'AUS Eastern Standard Time', , 0, u'AUS Eastern Daylight Time', , -60)) TIME_ZONE_ID_STANDARD = 1 TIME_ZONE_ID_DAYLIGHT = 2 TIME_ZONE_ID_UNKNOWN = 0 win32timezone.now = datetime.datetime(2012, 7, 26, 19, 47, 54, 235000, tzinfo=TimeZoneInfo(u'AUS Eastern Standard Time')) datetime.now = datetime.datetime(2012, 7, 26, 10, 47, 54, 235000) localtime = time.struct_time(tm_year=2012, tm_mon=7, tm_mday=26, tm_hour=10, tm_min=47, tm_sec=54, tm_wday=3, tm_yday=208, tm_isdst=1) so that does work when datetime.datetime.now() and time.localtime() don't. i've already replaced all uses of datetime.datetime.now() and time.localtime() with code to get the local time from a nearby linux host when necessary but i can change that to use the above methods. Many thanks, raf > On Wed, Jul 25, 2012 at 12:00 AM, wrote: > > > hi, > > > > i've just noticed the following wierdness with the time and datetime > > modules > > (python-2.6.2 and python-2.7.3) on three windows7 hosts and one windowsxp > > host (but not another xp host) and i'm wondering if anyone else has > > encountered this and knows how to fix it. > > > > the first problem is that time.timezone contains 0 instead of > > the usual -36000 (for Australia/Sydney). > > > > the second problem is that time.localtime(...).is_dst is wrong. > > time.tzname is also wrong but i care less about that. > > > > the demonstration code and output is below. i can fake the > > time.timezone being absent but i can't see any good way to > > deal with localtime not knowing when it's daylight savings. > > it appears to think it's DST when it isn't and vice versa. > > > > this all worked before the upgrades to the new windows7 hosts. > > the xp host that also exhibits the problem has recently had > > its PSU, MB, CPU and RAM replaced but the HDD remains the same. > > the xp host that doesn't exhibit the problem has all old hardware. > > so the common factor seems to be new hardware rather than > > specifically windows7. > > > > the third problem is that datetime.datetime.now() (and time.strftime() and > > time.localtime() and presumably time.time()) don't always return the > > current time. sometimes they do. sometimes the "current time" jumps back > > usually 9 hours for a while and then returns to normal. note that the > > current time that windows displays to the user is always correct. it's just > > python's idea of the current time that is wrong. > > > > all hosts have the correct timezone (i.e. Australia/Sydney or rather > > "(GMT +10:00) Canberra, Melbourne, Sydney" with automatic DST adjustment) > > and automatic time synchronisation. > > > > all hosts have the hardware clock in the local timezone and windows > > doesn't have the RealTimeIsUniversal=1 registry entry so it knows > > that the hardware clock is in the local timezone. so there's no > > confusion there. > > > > any help would be appreciated. > > > > cheers, > > raf > > > > #!/usr/bin/env python > > import time > > print('time.timezone = %r (should be -36000)' % time.timezone) > > print('time.tzname = %r (should be (\'EST\', \'EST\' or similar))' % > > (time.tzname,)) > > print('dst in june = %r (should be 0 (for Australia/Sydney))' % > > time.localtime(time.mktime((2012, 6, 1, 0, 0, 0, 0, 0, -1))).tm_isdst) > > print('dst in december = %r (should be 1 (for Australia/Sydney))' % > > time.localtime(time.mktime((2012, 12, 1, 0, 0, 0, 0, 0, -1))).tm_isdst) > > > > # Windows XP Professional Service Pack 3 (correct) > > # time.timezone = -36000 (should be -36000) > > # time.tzname = ('AUS Eastern Standard Time', 'AUS Eastern Daylight Time') > > (should be ('EST', 'EST') or similar) > > # dst in june = 0 (should be 0 (for Australia/Sydney)) > > # dst in december = 1 (should be 1 (for Australia/Sydney)) > > > > # Windows 7 and Windows XP Professional Service Pack 3 (incorrect) > > # time.timezone = 0 (should be -36000) > > # time.tzname = ('Aus', 'tra') (should be ('EST', 'EST') or similar) > > # dst in june = 1 (should be 0 (for Australia/Sydney)) > > # dst in december = 0 (should be 1 (for Australia/Sydney)) From ferdinandsousa at gmail.com Thu Jul 26 18:35:08 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Thu, 26 Jul 2012 22:05:08 +0530 Subject: [python-win32] time/datetime module wierdness on some windows7/XP PCs Message-ID: Hi List, Since Raf says that the motherboard was changed in one of the cases, I think it could be an issue with the BIOS clock settings. I have noticed on some OSes that there is a time setting "Set Hardware clock to UTC or localtime". This would imply timezone awareness in the BIOS. You might want to investigate this possibility as well. Ferdi -------------- next part -------------- An HTML attachment was scrubbed... URL: From janechen_1979 at yahoo.com Fri Jul 27 01:33:44 2012 From: janechen_1979 at yahoo.com (Jane Chen) Date: Thu, 26 Jul 2012 16:33:44 -0700 (PDT) Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: References: Message-ID: <1343345624.7454.YahooMailNeo@web164005.mail.gq1.yahoo.com> How can I know if my SD drive support the ioctl??I tested IOCTL_SFFDISK_DEVICE_COMMAND and it worked (did not get any errors.) However,?IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL is not working. If IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL is not supported, do you know other ways to tell if the device is SD card? Thank you, Jane Jane Chen wrote: > Thank you for your help! No luck so far. > > I wrote a C program and got the same results as python: Support for this ioctl is sporadic.? It may simply be that your SD drive doesn't support it. > Win 7 Notebook (with SD card inserted directly i.e. no SD card > reader) Error code: 1 ERROR_INVALID_FUNCTION.? There has to be an SD card reader somewhere. > Win 7 Notebook (without SD card inserted at all) Error code: 6 ERROR_INVALID_HANDLE > WinXP desktop (with USB stick but without SD card inserted at > all) Error code: 50 ERROR_FILE_EXISTS?? Remember that a USB stick will never support this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. ------------------------------ Message: 3 Date: Tue, 24 Jul 2012 12:09:05 +1000 From: Mark Hammond To: "Fox, Michael K" Cc: "python-win32 at python.org" Subject: Re: [python-win32] Need data type identifiers Message-ID: <500E03C1.4010706 at gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed All the other comments in this thread are correct, but one other thing you can do in recent pywin32 builds is to use win32com.client.VARIANT to override how a value is passed - search for 'win32com.client.VARIANT' in pywin32.chm for basic docs. HTH, Mark On 21/07/2012 1:55 PM, Fox, Michael K wrote: > We are having occasional difficulties when we need to pass an argument > in-and-out of a COM method that we are calling in Python.? There is some > magic in makepy that normally handles this for us but occasionally it > fails because it somehow reads the typelib incorrectly and > misunderstands the data type it must create.? Specifically, I have a C++ > method exposed to COM and it expects an empty SafeArray of two elements > (double floats) to be passed as an argument.? That method revises the > array, filling it with two values.? We have found that makepy assigns > some sort of identifier to each data type.? For instance an array of > strings is assigned (24584, 3)and an array of variants is assigned > (24588, 3) as shown in the line of code below, taken from one of the > wrappers created by Makepy. > > def*GetDirection*(/self/, oDirection=(0,0)): > > return/self/._ApplyTypes_(1611137025, 1, (24, 0), ((24588,3),), > u/'GetDirection'/, None, oDirection) > > Occasionally pywin32 assigns the wrong identifier then the argument is > cast as the wrong data type and an error is thrown.? We stumbled upon > the correct identifier and when we corrected the identifier assigned by > Makepy then we were able to call the method without throwing an error. > Where can we find a list of these identifiers? > > *Mike Fox* > > > > _______________________________________________ > 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 End of python-win32 Digest, Vol 112, Issue 24 ********************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jul 27 19:29:28 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 27 Jul 2012 10:29:28 -0700 Subject: [python-win32] Does pywin32 support SD card operation(IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL)? In-Reply-To: <1343345624.7454.YahooMailNeo@web164005.mail.gq1.yahoo.com> References: <1343345624.7454.YahooMailNeo@web164005.mail.gq1.yahoo.com> Message-ID: <5012CFF8.604@probo.com> Jane Chen wrote: > How can I know if my SD drive support the ioctl? I tested > IOCTL_SFFDISK_DEVICE_COMMAND and it worked (did not get any errors.) > However, IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL is not working. Well, frankly, if the volume driver rejects the ioctl, then it probably isn't supported. I think you are now calling the ioctl correctly, so if it were supported, you should have received a response. > If IOCTL_SFFDISK_QUERY_DEVICE_PROTOCOL is not supported, do you know > other ways to tell if the device is SD card? No. Why would you need to know this? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From amauryfa at gmail.com Sat Jul 28 11:44:12 2012 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Sat, 28 Jul 2012 11:44:12 +0200 Subject: [python-win32] Modules installed in the Windows registry Message-ID: Hello, You probably know that Python3.3 has a completely new implementation of the import system: http://docs.python.org/dev/whatsnew/3.3.html#using-importlib-as-the-implementation-of-import (yes, import is now written in Python!) But there is a missing feature: it has always been possible to install Python modules in the Windows registry: "import foobar" would open the registry key "Software\Python\PythonCore\3.2\Modules\foobar"; if a file name is found there, it's used to import the module; this effectively bypasses the search in sys.path. I know that pywin32 used to install its modules this way in the old times. Nowadays the same feature can be achieved differently, by using sys.meta_path for example. Is this feature still used? Where? Is it acceptable to not support it anymore, and suggest developers to use a more modern method? -- Amaury Forgeot d'Arc From rupole at hotmail.com Sat Jul 28 21:11:35 2012 From: rupole at hotmail.com (Roger Upole) Date: Sat, 28 Jul 2012 15:11:35 -0400 Subject: [python-win32] Modules installed in the Windows registry References: Message-ID: Amaury Forgeot d'Arc wrote: > Hello, > > You probably know that Python3.3 has a completely new implementation > of the import system: > http://docs.python.org/dev/whatsnew/3.3.html#using-importlib-as-the-implementation-of-import > (yes, import is now written in Python!) > > But there is a missing feature: it has always been possible to install > Python modules in the Windows registry: "import foobar" would open > the registry key "Software\Python\PythonCore\3.2\Modules\foobar"; if a > file name is found there, it's used to import the module; this > effectively bypasses the search in sys.path. > > I know that pywin32 used to install its modules this way in the old > times. Nowadays the same feature can be achieved differently, by > using sys.meta_path for example. > > Is this feature still used? Where? > Is it acceptable to not support it anymore, and suggest developers to > use a more modern method? > > > -- > Amaury Forgeot d'Arc Pywin32 hasn't used that feature for some time, and the installer goes out of its way to remove any entries under that registry key that might have been left over from an older version. I haven't seen any modules from other packages registered this way in ages. Roger From raf at raf.org Mon Jul 30 03:52:00 2012 From: raf at raf.org (raf) Date: Mon, 30 Jul 2012 11:52:00 +1000 Subject: [python-win32] time/datetime module wierdness on some windows7/XP PCs [SOLVED] In-Reply-To: <20120726101535.GA15398@raf.org> References: <20120723063647.GA29042@raf.org> <20120725060033.GA28747@raf.org> <20120726101535.GA15398@raf.org> Message-ID: <20120730015200.GB2285@raf.org> hi, i finally worked out what was causing the timezone problem. all of the affected machines had a recent version of cygwin installed which sets the TZ environment variable using zoneinfo names such as "Australia/Sydney". the unaffected machine had an older version of cygwin which doesn't set the TZ environment variable. windows doesn't understand this notation and so interprets it using its own rules. it saw "Aus" as the three-letter code for the standard timezone. there was no +|- offset so it saw that as meaning UTC. it saw the next three letters, "tra" as the three-letter code for the daylight savings timezone. presumably "Aus" and "tra" mean nothing as timezone codes but it ended up interpreting "Australia/Sydney" as if it were GMT+0100 (i.e. GMT but with daylight savings in effect). this explains the clock seeming to jump back and forth 9 hours several times a day. the correct times were from python programs that weren't invoked via cygwin and the incorrect times were from python programs that were invoked via cygwin. the solution was to place the following code before the first import of the time or datetime modules: # Note: We need to unset the TZ environment variable on Windows which is set # by Cygwin using the UNIX naming convention (e.g. "Australia/Sydney") as # this will be interpreted by the underlying Windows system using a # completely different specification language (e.g. "EST+10:00EDT") thus # creating timezone havoc. Leaving it empty results in the local timezone # being used which is what we want. Also note that we need to do this before # the time or datetime modules have been imported or it has no effect. import sys, os if sys.platform == 'win32': _tz = os.getenv('TZ') if _tz is not None and '/' in _tz: os.unsetenv('TZ') removing the TZ environment variable entirely wasn't an option as it is needed by cygwin programs such as ls. cheers, raf From michael.k.fox at boeing.com Mon Jul 30 19:56:18 2012 From: michael.k.fox at boeing.com (Fox, Michael K) Date: Mon, 30 Jul 2012 10:56:18 -0700 Subject: [python-win32] Need data type identifiers Message-ID: Thanks Mark. That's exactly what we needed. Mike Fox > All the other comments in this thread are correct, but one other thing > you can do in recent pywin32 builds is to use win32com.client.VARIANT to > override how a value is passed - search for 'win32com.client.VARIANT' in > pywin32.chm for basic docs. > > HTH, > > Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: