From bramesh.vt at gmail.com Mon Feb 3 19:06:40 2014 From: bramesh.vt at gmail.com (Bharath Ramesh) Date: Mon, 3 Feb 2014 10:06:40 -0800 Subject: [python-win32] Building Python-2.7.6 for 64bit Windows In-Reply-To: <52EBEFBD.9060704@probo.com> References: <52EBEFBD.9060704@probo.com> Message-ID: On Fri, Jan 31, 2014 at 10:47 AM, Tim Roberts wrote: > Bharath Ramesh wrote: >> We use numerous third party libraries, one being PyOpenSSL We have >> already rebuilt it with a newer version of OpenSSL. We continue to >> have the same issue. We have some part of the code that make secure >> connection using sockets, I think those end up using the ssl module >> from Python. However, I am not the one who debugged this to be this >> issue on windows > > I need to back off of my original assertion, because I was wrong. The > Python ssl module does use OpenSSL. I didn't see it doing any imports, > so I assumed it was using something else. > > However, it links to it statically, so there shouldn't be any DLL conflicts. > > >> Another team member who had debugged the windows side of our project. >> Unfortunately, I am no windows expert and he was the one who done the >> initial debugging and come to the conclusion that the issue is with >> regards to multiple OpenSSL dll being loaded into the same address >> space. He is not part of our team any more and I am faced with >> rebuilding all our tools to ensure consistency. > > It is not generally possible to load multiple versions of a single DLL > in Windows. The system loader will satisfy the externals from the > already loaded version. You certainly can have multiple copies of a > statically linked library, but it's not clear to me how that would cause > any problems. > I am not sure if I am correct in describing what is possibly happening. I have OpenSSL statically compiled with Python v0.9.8. I have another third party library that uses another version of OpenSSL 1.0.1, linked dynamically. My application is dynamically linked with the same version of OpenSSL as the third party library. During the execution of my application. I load Python to run some code and that code then tries to interact with the third party library linked dynamically. Would newer version of OpenSSL DLL be loaded or would it be satisfied with the version of OpenSSL statically loaded. > >> I am not subscribed to the list would appreciate if I am copied on the reply. > > Then please be sure to cc the list. And wouldn't it be easier just to > join the list until your issue is resolved? I have subscribed to the list now. I discussed the issue you had raised with our team, but the consensus was to go ahead and build Python with a newer version of OpenSSL. So I would still need help in building OpenSSL. I have managed to build Python on windows now as standalone without using our build system. I see numerous warnings during this time basically issues with size mismatch like: ..\Python\Python-ast.c(3348) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data Is there anyway these warning could be fixed without modifying the code. I am using the vsbuild to build python using pcbuild.sln file. I am building it for 64 bit windows. I dont see these errors on the 32bit build. From timr at probo.com Mon Feb 3 20:44:31 2014 From: timr at probo.com (Tim Roberts) Date: Mon, 3 Feb 2014 11:44:31 -0800 Subject: [python-win32] Building Python-2.7.6 for 64bit Windows In-Reply-To: References: <52EBEFBD.9060704@probo.com> Message-ID: <52EFF19F.8060405@probo.com> Bharath Ramesh wrote: > I am not sure if I am correct in describing what is possibly > happening. I have OpenSSL statically compiled with Python v0.9.8. I > have another third party library that uses another version of OpenSSL > 1.0.1, linked dynamically. My application is dynamically linked with > the same version of OpenSSL as the third party library. During the > execution of my application. I load Python to run some code and that > code then tries to interact with the third party library linked > dynamically. Would newer version of OpenSSL DLL be loaded or would it > be satisfied with the version of OpenSSL statically loaded. The Python ssl module will always use its statically linked library. It doesn't care which dynamic libraries are loaded -- the external references it needs were already satisfied at link time. > I discussed the issue you had raised with our team, but the consensus > was to go ahead and build Python with a newer version of OpenSSL. So I > would still need help in building OpenSSL. I have managed to build > Python on windows now as standalone without using our build system. I > see numerous warnings during this time basically issues with size > mismatch like: > ..\Python\Python-ast.c(3348) : warning C4244: 'function' : conversion > from 'Py_ssize_t' to 'int', possible loss of data > > Is there anyway these warning could be fixed without modifying the > code. I am using the vsbuild to build python using pcbuild.sln file. I > am building it for 64 bit windows. I dont see these errors on the > 32bit build. Right, because size_t and int are the same size in a 32-bit build. And on Linux, size_t and int are also the same size in a 64-bit build. But on Windows, in 64-bit land, size_t is 64 bits and int is 32 bits. The warnings can't be fixed without either modifying the code, or switching to a gcc compiler. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bramesh.vt at gmail.com Mon Feb 3 23:43:39 2014 From: bramesh.vt at gmail.com (Bharath Ramesh) Date: Mon, 3 Feb 2014 14:43:39 -0800 Subject: [python-win32] Building Python-2.7.6 for 64bit Windows In-Reply-To: <52EFF19F.8060405@probo.com> References: <52EBEFBD.9060704@probo.com> <52EFF19F.8060405@probo.com> Message-ID: On Mon, Feb 3, 2014 at 11:44 AM, Tim Roberts wrote: > Bharath Ramesh wrote: >> I am not sure if I am correct in describing what is possibly >> happening. I have OpenSSL statically compiled with Python v0.9.8. I >> have another third party library that uses another version of OpenSSL >> 1.0.1, linked dynamically. My application is dynamically linked with >> the same version of OpenSSL as the third party library. During the >> execution of my application. I load Python to run some code and that >> code then tries to interact with the third party library linked >> dynamically. Would newer version of OpenSSL DLL be loaded or would it >> be satisfied with the version of OpenSSL statically loaded. > > The Python ssl module will always use its statically linked library. It > doesn't care which dynamic libraries are loaded -- the external > references it needs were already satisfied at link time. Would it affect other packages that are linked dynamically? -- Bharath From timr at probo.com Tue Feb 4 00:28:48 2014 From: timr at probo.com (Tim Roberts) Date: Mon, 3 Feb 2014 15:28:48 -0800 Subject: [python-win32] Building Python-2.7.6 for 64bit Windows In-Reply-To: References: <52EBEFBD.9060704@probo.com> <52EFF19F.8060405@probo.com> Message-ID: <52F02630.4080502@probo.com> Bharath Ramesh wrote: > On Mon, Feb 3, 2014 at 11:44 AM, Tim Roberts wrote: >> >> The Python ssl module will always use its statically linked library. It >> doesn't care which dynamic libraries are loaded -- the external >> references it needs were already satisfied at link time. > Would it affect other packages that are linked dynamically? I'm not sure what you're asking. If you have loaded OpenSSL 1.0.1 dynamically, and some other package comes in that links to OpenSSL dynamically, then it should get your 1.0.1 version. The Python ssl module's static linking won't affect any other modules. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From reckoner at gmail.com Tue Feb 4 19:51:46 2014 From: reckoner at gmail.com (reckoner) Date: Tue, 04 Feb 2014 10:51:46 -0800 Subject: [python-win32] Programmatically turn off mouse auto-positioning Message-ID: <52F136C2.9010304@gmail.com> Hi, In the control panel, under mouse settings, there is a checkbox to automatically move the mouse to the "default button in a dialog box". Is there a way to programmatically turn this off/on using Python? I'm referring to windows 7/8. Thanks! From mail at timgolden.me.uk Tue Feb 4 20:26:54 2014 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 04 Feb 2014 19:26:54 +0000 Subject: [python-win32] Programmatically turn off mouse auto-positioning In-Reply-To: <52F136C2.9010304@gmail.com> References: <52F136C2.9010304@gmail.com> Message-ID: <52F13EFE.9060405@timgolden.me.uk> On 04/02/2014 18:51, reckoner wrote: > In the control panel, under mouse settings, there is a checkbox to > automatically move the mouse to the "default button in a dialog box". > > Is there a way to programmatically turn this off/on using Python? I'm > referring to windows 7/8. While I don't know the answer directly, a pound to a penny it's basically a registry entry. If you either search for that, or just use process explorer or something similar to monitor registry changes, you can then use the built-in winreg module or win32api's registry functions to achieve the same effect. TJG From timr at probo.com Tue Feb 4 20:49:16 2014 From: timr at probo.com (Tim Roberts) Date: Tue, 4 Feb 2014 11:49:16 -0800 Subject: [python-win32] Programmatically turn off mouse auto-positioning In-Reply-To: <52F136C2.9010304@gmail.com> References: <52F136C2.9010304@gmail.com> Message-ID: <52F1443C.70903@probo.com> reckoner wrote: > In the control panel, under mouse settings, there is a checkbox to > automatically move the mouse to the "default button in a dialog box". > > Is there a way to programmatically turn this off/on using Python? I'm > referring to windows 7/8. It would be extremely bad form for you to do so. That's a user preference. I think it's a silly preference, but if that's what the user wants, it is NOT your place (as an application) to contradict him. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at ctypes.org Tue Feb 4 21:22:23 2014 From: theller at ctypes.org (Thomas Heller) Date: Tue, 04 Feb 2014 21:22:23 +0100 Subject: [python-win32] Programmatically turn off mouse auto-positioning In-Reply-To: <52F136C2.9010304@gmail.com> References: <52F136C2.9010304@gmail.com> Message-ID: Am 04.02.2014 19:51, schrieb reckoner: > Hi, > > In the control panel, under mouse settings, there is a checkbox to > automatically move the mouse to the "default button in a dialog box". > > Is there a way to programmatically turn this off/on using Python? I'm > referring to windows 7/8. > > Thanks! SystemParametersInfo with the SPI_SETSNAPTODEFBUTTON parameter. No idea if pywin32 exposes this but there's always ctypes. Thomas From reckoner at gmail.com Fri Feb 7 14:29:05 2014 From: reckoner at gmail.com (reckoner) Date: Fri, 07 Feb 2014 05:29:05 -0800 Subject: [python-win32] Programmatically turn off mouse auto-positioning Message-ID: <52F4DFA1.9010108@gmail.com> > Am 04.02.2014 19:51, schrieb reckoner: > > Hi, > > > > In the control panel, under mouse settings, there is a checkbox to > > automatically move the mouse to the "default button in a dialog box". > > > > Is there a way to programmatically turn this off/on using Python? I'm > > referring to windows 7/8. > > > > Thanks! > > SystemParametersInfo with the SPI_SETSNAPTODEFBUTTON parameter. > No idea if pywin32 exposes this but there's always ctypes. Thanks for the tip! For posterity, here it is: def set_mouse_autosnap_to_default(state): """The mouse is auto-positioned in the control panel. This turns on/off this auto-snap. :state: True/False (set to bool) """ h = ctypes.c_void_p() # set postion ctypes.windll.user32.SystemParametersInfoW(0x60,state,ctypes.byref(h),0) # recover position # print ctypes.windll.user32.SystemParametersInfoW(0x5F,0,ctypes.byref(h),0) From cappy2112 at gmail.com Sat Feb 15 03:01:23 2014 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 14 Feb 2014 18:01:23 -0800 Subject: [python-win32] optimizing code to read serial port Message-ID: Regarding an in-house python program we use for dumping diagnostic data over a serial port on Windows 7 ... I'm trying to determine if it's possible optimize the python code so that dumping the data will occur faster. Currently, it takes ~25 minutes at 9600 baud to dump 8-15 MB of data. Going to higher baud rates does reduce this time, but depending on which PC is running the program, going to higher baud rates often results in ill-formed data. The serial port on the device we are dumping data from has a 2-wire interface (no handshaking). Sometimes 115200 baud works fine, other times the data gets all jumbled. We've decided to default to 9600 to avoid getting jumbled data. Compared to an openly available terminal program (Tera Term Pro) written in a compiled language, our Python version is much slower, but easier to program. Tera Term's scripting language isn't as easy to script with as Python. At the lowest level of the Python app, the last call in python is win32file.ReadFile( comport, bytes_, None ). I believe execution goes to a PyWin32 extension module at this point. By default, 1 is passed in for the number of bytes to read. I thought this was very inefficient, so I've experimented with values like 2,4,8,16. I didn't want to go higher than 16 because the serial port FIFO on many PCs isn't any larger than 16. While using cProfile, I could see that the number of function calls executed was cut in half, each time the # of bytes read doubled. Normally this would be a win, but the total time to dump the same amount of data over the serial port would almost double also. While this may not be strictly a Python-specific issue, the performance issue may be related to the Python-Win32 interface. For example, are there more efficient ways to read data from a serial port using Python, than calling win32file.ReadFile() ? I would also expect reading more 8-16 bytes at a time to be more efficient than reading 1 byte. I do expect that buffering weighs in heavily here, but I have no control over what the serial hardware does nor how windows interacts with it. Having read several of the Python optimization tips, I've already eliminated string concatenation, replaced globals variables with locals, and eliminated several dot references that are inside of loops.There doesn't seem to be any places I can use calls to map() or replace for loops with list/gen comps. There is too much code in the app to post here. I know it's difficult to comment on code that you can't see. The Python app is a single-threaded console app running on Python 2.7, but we've seen the same performance issues as far back as Python 2.3 on Windows XP. I've finally decided to investigate this because users of the program are complaining about the time to dump the data. I would appreciate your thoughts on this issue. thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Sat Feb 15 11:32:48 2014 From: vernondcole at gmail.com (Vernon D. Cole) Date: Sat, 15 Feb 2014 11:32:48 +0100 Subject: [python-win32] optimizing code to read serial port In-Reply-To: References: Message-ID: Tony: Don't do it! Do not attempt to make your data transfer faster while using this defective hardware design! Trust me on this. I have been doing serial port data transfer since 300 baud was fast. The problem with your data transfer speed is not your program optimization. It is contained in the sentence: "The serial port on the device we are dumping data from has a 2-wire interface (no handshaking)." This means that the program servicing the serial port must be scheduled at time intervals less than the time needed to fill your FIFO buffer. Using Windows, you cannot guarantee that with any degree of certainty -- particularly not at higher data rates -- because you have no control over the hardware-level interface drivers. If you really want higher data rates, you must use a dedicated device to receive the data. May I humbly suggest that an hour of your programming time would purchase a single board computer with a Python engine? Look at http://www.raspberrypi.org/. Let the SBC collect the data. Transfer blocks from it to the Windows environment using a more reliable protocol. Consider that none of the new Windows boxes I saw on my last shopping trip had serial ports. You will soon need to be using another solution anyway. On Sat, Feb 15, 2014 at 3:01 AM, Tony Cappellini wrote: > > > > Regarding an in-house python program we use for dumping diagnostic data > over a serial port on Windows 7 ... > > > I'm trying to determine if it's possible optimize the python code so that > dumping the data will occur faster. Currently, it takes ~25 minutes at 9600 > baud to dump 8-15 MB of data. Going to higher baud rates does reduce this > time, but depending on which PC is running the program, going to higher > baud rates often results in ill-formed data. The serial port on the device > we are dumping data from has a 2-wire interface (no handshaking). Sometimes > 115200 baud works fine, other times the data gets all jumbled. We've > decided to default to 9600 to avoid getting jumbled data. > > Compared to an openly available terminal program (Tera Term Pro) written > in a compiled language, our Python version is much slower, but easier to > program. Tera Term's scripting language isn't as easy to script with as > Python. > > At the lowest level of the Python app, the last call in python is > win32file.ReadFile( comport, bytes_, None ). I believe execution goes to a > PyWin32 extension module at this point. > > By default, 1 is passed in for the number of bytes to read. I thought this > was very inefficient, > so I've experimented with values like 2,4,8,16. I didn't want to go higher > than 16 because the serial port FIFO on many PCs isn't any larger than 16. > > While using cProfile, I could see that the number of function calls > executed was cut in half, > each time the # of bytes read doubled. Normally this would be a win, but > the total time to dump the same amount of data over the serial port would > almost double also. > > While this may not be strictly a Python-specific issue, the performance > issue may be related to the Python-Win32 interface. For example, are there > more efficient ways to read data from a serial port using Python, than > calling win32file.ReadFile() ? > > I would also expect reading more 8-16 bytes at a time to be more efficient > than reading 1 byte. > I do expect that buffering weighs in heavily here, but I have no control > over what the serial hardware does nor how windows interacts with it. > > Having read several of the Python optimization tips, I've already > eliminated string concatenation, replaced globals variables with locals, > and eliminated several dot references that are inside of loops.There > doesn't seem to be any places I can use calls to map() or replace for loops > with list/gen comps. > > There is too much code in the app to post here. I know it's difficult to > comment on code that you can't see. > > The Python app is a single-threaded console app running on Python 2.7, but > we've seen the same performance issues as far back as Python 2.3 on Windows > XP. I've finally decided to investigate this because users of the program > are complaining about the time to dump the data. > > I would appreciate your thoughts on this issue. > > thanks > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Sat Feb 15 17:14:33 2014 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sat, 15 Feb 2014 08:14:33 -0800 Subject: [python-win32] optimizing code to read serial port Message-ID: Vernon Your suggestion is interesting but not practical for our needs. We are collecting data from many devices that have failed tests, and often have 10 or more failed devices that we need to collect the data from. These are scattered all over a large lab environment. I have a Raspberry Pi, and may try your suggestion on 1 device just to see the result. Do you have any ides why running a terminal program written in (presumably C, mentioned in my original message) doesn't seem to suffer from the problems that my python app does, even when transferring the data at much higher baud rates? >>You will soon need to be using another solution anyway. We've been using USB-serial adapters for a long time. Thanks On Sat, Feb 15, 2014 at 2:32 AM, Vernon D. Cole wrote: > Tony: > > Don't do it! > > Do not attempt to make your data transfer faster while using this > defective hardware design! Trust me on this. I have been doing serial > port data transfer since 300 baud was fast. > > The problem with your data transfer speed is not your program > optimization. It is contained in the sentence: "The serial port on the > device we are dumping data from has a 2-wire interface (no handshaking)." > This means that the program servicing the serial port must be scheduled at > time intervals less than the time needed to fill your FIFO buffer. Using > Windows, you cannot guarantee that with any degree of certainty -- > particularly not at higher data rates -- because you have no control over > the hardware-level interface drivers. > > If you really want higher data rates, you must use a dedicated device to > receive the data. May I humbly suggest that an hour of your programming > time would purchase a single board computer with a Python engine? Look at > http://www.raspberrypi.org/. Let the SBC collect the data. Transfer > blocks from it to the Windows environment using a more reliable protocol. > > Consider that none of the new Windows boxes I saw on my last shopping trip > had serial ports. You will soon need to be using another solution anyway. > > > > > > > > On Sat, Feb 15, 2014 at 3:01 AM, Tony Cappellini wrote: > >> >> >> >> Regarding an in-house python program we use for dumping diagnostic data >> over a serial port on Windows 7 ... >> >> >> I'm trying to determine if it's possible optimize the python code so that >> dumping the data will occur faster. Currently, it takes ~25 minutes at 9600 >> baud to dump 8-15 MB of data. Going to higher baud rates does reduce this >> time, but depending on which PC is running the program, going to higher >> baud rates often results in ill-formed data. The serial port on the device >> we are dumping data from has a 2-wire interface (no handshaking). Sometimes >> 115200 baud works fine, other times the data gets all jumbled. We've >> decided to default to 9600 to avoid getting jumbled data. >> >> Compared to an openly available terminal program (Tera Term Pro) written >> in a compiled language, our Python version is much slower, but easier to >> program. Tera Term's scripting language isn't as easy to script with as >> Python. >> >> At the lowest level of the Python app, the last call in python is >> win32file.ReadFile( comport, bytes_, None ). I believe execution goes to >> a PyWin32 extension module at this point. >> >> By default, 1 is passed in for the number of bytes to read. I thought >> this was very inefficient, >> so I've experimented with values like 2,4,8,16. I didn't want to go >> higher than 16 because the serial port FIFO on many PCs isn't any larger >> than 16. >> >> While using cProfile, I could see that the number of function calls >> executed was cut in half, >> each time the # of bytes read doubled. Normally this would be a win, but >> the total time to dump the same amount of data over the serial port would >> almost double also. >> >> While this may not be strictly a Python-specific issue, the performance >> issue may be related to the Python-Win32 interface. For example, are there >> more efficient ways to read data from a serial port using Python, than >> calling win32file.ReadFile() ? >> >> I would also expect reading more 8-16 bytes at a time to be more >> efficient than reading 1 byte. >> I do expect that buffering weighs in heavily here, but I have no control >> over what the serial hardware does nor how windows interacts with it. >> >> Having read several of the Python optimization tips, I've already >> eliminated string concatenation, replaced globals variables with locals, >> and eliminated several dot references that are inside of loops.There >> doesn't seem to be any places I can use calls to map() or replace for loops >> with list/gen comps. >> >> There is too much code in the app to post here. I know it's difficult to >> comment on code that you can't see. >> >> The Python app is a single-threaded console app running on Python 2.7, >> but we've seen the same performance issues as far back as Python 2.3 on >> Windows XP. I've finally decided to investigate this because users of the >> program are complaining about the time to dump the data. >> >> I would appreciate your thoughts on this issue. >> >> thanks >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Sat Feb 15 18:55:52 2014 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sat, 15 Feb 2014 09:55:52 -0800 Subject: [python-win32] optimizing code to read serial port In-Reply-To: <201402151740.s1FHe2OU002183@blue-cove.com> References: <201402151740.s1FHe2OU002183@blue-cove.com> Message-ID: No, I haven't. But I'd be happy to give it a try. Chances are the serial I/O with this package are more efficient than the way my program is doing it now. Thanks for that tip. I'm also considering compiling my app to a compiled exe using PyPy, once I understand the compiler requirements for Windows. On Sat, Feb 15, 2014 at 9:40 AM, RayS wrote: > At 08:14 AM 2/15/2014, you wrote: > > Vernon > > Your suggestion is interesting but not practical for our needs. > > > Have you profiled pySerial? http://pyserial.sourceforge.net/examples.html > I use it in my LX200 serial telescope package > http://rjs.org/Python/LX200/LXSerial.py/LXSerial.html > http://rjs.org/Python/LX200.zip > > - Ray > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Sat Feb 15 20:04:43 2014 From: vernondcole at gmail.com (Vernon D. Cole) Date: Sat, 15 Feb 2014 12:04:43 -0700 Subject: [python-win32] optimizing code to read serial port In-Reply-To: References: <201402151740.s1FHe2OU002183@blue-cove.com> Message-ID: I second the suggestion to try pySerial. I have used it for years to control RS-232 equipment -- don't know why I did not think of that. Like Terra-Term, pySerial will use device-level, rather than file-level APIs to talk to the UART. Of course, your success will depend a great deal on the skill of the programmer who wrote the driver for your USB-serial device. The important part of the work is done in the driver when it processes interrupts in Kernel mode. The USB adapter I tried -- well, lets just say it's still sitting in a box of loose parts. That's why I have been contemplating a Raspberry Pi purchase myself. Perhaps we should take this discussion off line and compare notes. > > On Sat, Feb 15, 2014 at 9:40 AM, RayS wrote: >> >> At 08:14 AM 2/15/2014, you wrote: >> >> Vernon >> >> Your suggestion is interesting but not practical for our needs. >> >> >> Have you profiled pySerial? http://pyserial.sourceforge.net/examples.html >> I use it in my LX200 serial telescope package >> http://rjs.org/Python/LX200/LXSerial.py/LXSerial.html >> http://rjs.org/Python/LX200.zip >> >> - Ray >> > From cappy2112 at gmail.com Sat Feb 15 20:17:59 2014 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sat, 15 Feb 2014 11:17:59 -0800 Subject: [python-win32] optimizing code to read serial port In-Reply-To: References: <201402151740.s1FHe2OU002183@blue-cove.com> Message-ID: >> I second the suggestion to try pySerial. I have used it for years to >>control RS-232 equipment -- don't know why I did not think of that. >>Like Terra-Term, pySerial will use device-level, rather than >>file-level APIs to talk to the UART. I was hoping to hear something exactly like this comment, since I'm not very familiar with the details of the winapi, and suspected there may be several ways to talk to a serial port. As far as the drivers, when I'm not using a USB-seral adapter, the serial port driver is coming straight from Redmond. I will give this a try, then post some results. On Sat, Feb 15, 2014 at 11:04 AM, Vernon D. Cole wrote: > I second the suggestion to try pySerial. I have used it for years to > control RS-232 equipment -- don't know why I did not think of that. > Like Terra-Term, pySerial will use device-level, rather than > file-level APIs to talk to the UART. > > Of course, your success will depend a great deal on the skill of the > programmer who wrote the driver for your USB-serial device. The > important part of the work is done in the driver when it processes > interrupts in Kernel mode. The USB adapter I tried -- well, lets just > say it's still sitting in a box of loose parts. That's why I have been > contemplating a Raspberry Pi purchase myself. Perhaps we should take > this discussion off line and compare notes. > > > > > On Sat, Feb 15, 2014 at 9:40 AM, RayS wrote: > >> > >> At 08:14 AM 2/15/2014, you wrote: > >> > >> Vernon > >> > >> Your suggestion is interesting but not practical for our needs. > >> > >> > >> Have you profiled pySerial? > http://pyserial.sourceforge.net/examples.html > >> I use it in my LX200 serial telescope package > >> http://rjs.org/Python/LX200/LXSerial.py/LXSerial.html > >> http://rjs.org/Python/LX200.zip > >> > >> - Ray > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Sun Feb 16 00:02:45 2014 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 16 Feb 2014 12:02:45 +1300 Subject: [python-win32] optimizing code to read serial port In-Reply-To: References: Message-ID: <52FFF215.9000908@canterbury.ac.nz> Tony Cappellini wrote: > Do you have any ides why running a terminal program written in > (presumably C, mentioned in my original message) doesn't seem to suffer > from the problems that my python app does, even when transferring the > data at much higher baud rates? Could the terminal program possibly be using some protocol such as xon/xoff for flow control? If so, that might account for the difference. -- Greg From usfree74 at gmail.com Sun Feb 16 04:32:24 2014 From: usfree74 at gmail.com (Xin Zhao) Date: Sat, 15 Feb 2014 19:32:24 -0800 Subject: [python-win32] comtypes + mshtml was slow to me, any suggestion? Message-ID: Hey, I am trying to build a test tool using comtypes and mshtml to handle some applications that have IE activex control, which renders some logics predefined in an HTML file. But I have two issues: 1. I did "from comtypes.client import GetModule" and then "GetModule('mshtml.tlb')". It took a few minutes to finish this function. The second run was faster, but still took about 6 seconds. Is this normal? 2. I usee comtypes to get IHTMLDocument2 interface, and then enumerate all HTML elements in the application. But for some page, it took more than 2 minutes to process. This seems to be way too slow. I think I must miss something. But have no clue about it. Can someone help? Thanks, -X -------------- next part -------------- An HTML attachment was scrubbed... URL: From rays at blue-cove.com Sat Feb 15 18:40:03 2014 From: rays at blue-cove.com (RayS) Date: Sat, 15 Feb 2014 09:40:03 -0800 Subject: [python-win32] optimizing code to read serial port In-Reply-To: References: Message-ID: <201402151740.s1FHe2OU002183@blue-cove.com> At 08:14 AM 2/15/2014, you wrote: >Vernon > >Your suggestion is interesting but not practical for our needs. Have you profiled pySerial? http://pyserial.sourceforge.net/examples.html I use it in my LX200 serial telescope package http://rjs.org/Python/LX200/LXSerial.py/LXSerial.html http://rjs.org/Python/LX200.zip - Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sun Feb 16 09:05:21 2014 From: timr at probo.com (Tim Roberts) Date: Sun, 16 Feb 2014 00:05:21 -0800 Subject: [python-win32] optimizing code to read serial port In-Reply-To: References: Message-ID: On Feb 14, 2014, at 6:01 PM, Tony Cappellini > wrote: I'm trying to determine if it's possible optimize the python code so that dumping the data will occur faster. Currently, it takes ~25 minutes at 9600 baud to dump 8-15 MB of data. There?s something wrong with your math. At 9600 baud, you average just under 1,000 bytes per second. At 1,000 bytes per second, 15 MB will take 15,000 seconds, which is just over 4 hours. That?s straight wire time ? it doesn?t matter what language you?re using to pack the wire. 25 minutes will get you 1.5MB. So, either you?re not really running 9600 baud, or you?re not really sending as much data as you think you are. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Sun Feb 16 19:59:34 2014 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sun, 16 Feb 2014 10:59:34 -0800 Subject: [python-win32] optimizing code to read serial port Message-ID: Message: 1 Date: Sun, 16 Feb 2014 12:02:45 +1300 From: Greg Ewing To: python-win32 Subject: Re: [python-win32] optimizing code to read serial port Message-ID: <52FFF215.9000908 at canterbury.ac.nz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>Could the terminal program possibly be using some >>protocol such as xon/xoff for flow control? If so, >>that might account for the difference. It does support that option, but we use the default settings which is no control flow - for that terminal program. There is a ini file which is distributed on every system we use for collecting the diagnostic data. The settings in that ini file are 8N1 9600, No control flow. -------------- next part -------------- An HTML attachment was scrubbed... URL: From reabow at gmail.com Tue Feb 18 19:59:54 2014 From: reabow at gmail.com (Aaron Reabow) Date: Tue, 18 Feb 2014 20:59:54 +0200 Subject: [python-win32] List of keys and values Message-ID: Hi Guys, This should be dead simple. I am just trying to find a list of all of the key value pairs held for each message. These are the ones that I have found so far: - subject - SenderName - Recipients - TaskDueDate I am using this simple code snippet import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case, # the inbox. You can change that number to reference # any other folder messages = inbox.Items message = messages.GetLast() then doing this for eample: for message in messages: print message.TaskDueDate i was wondering what else I can get access to for a message? many thanks in advance, Aaron -- Aaron Reabow +27 83 649 7567 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jacob at blindza.co.za Tue Feb 18 20:59:48 2014 From: jacob at blindza.co.za (Jacob Kruger) Date: Tue, 18 Feb 2014 21:59:48 +0200 Subject: [python-win32] win32gui cursor position tracking etc. Message-ID: Firstly, I know the following can retrieve mouse cursor position coordinates easily enough: import win32gui tPos = win32gui.GetCursorPos() But, while something like .GetCursorInfo looks promising, I am struggling to find more info about what the first two returned items are - one of them seems to be an integer which almost matches the same value you get returned using just .GetCursor(), but, the main thing is while the mouse cursor coordinates are useful, etc., the main thing I actually want to be able to retrieve at this stage is the current position/coordinates of either the currently focused item, or the keyboard/PC cursor - as in, for example, if your mouse is hovering higher up on screen, but, lower down you're typing text in some or other text box, etc., and, primary issue is that I would prefer to just be able to track the cursor itself, since the control elements/interface the user may be involved in using will be a separate piece of software, etc. - as in, I actually want to do something more along the lines of double checking if the computer is in active use, and, while am pretty sure wouldn't be able to intercept keystrokes - don't want to- but something similar to being able to easily track position/coordinates of mouse cursor is what am trying to implement, and issue is also that for example with forms of accessibility software like my screenreader, I might at times not really use the mouse cursor for quite a while at all, since I primarily just navigate whole operating system using cursor and tab keys, along with keyboard invocation of menu systems, control shortcut keys, etc.. Suggestions? Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' -------------- next part -------------- An HTML attachment was scrubbed... URL: From jacob at blindza.co.za Wed Feb 19 08:16:05 2014 From: jacob at blindza.co.za (Jacob Kruger) Date: Wed, 19 Feb 2014 09:16:05 +0200 Subject: [python-win32] win32gui cursor position tracking etc. In-Reply-To: References: Message-ID: Ok, figured out workaround that does pretty much what I want: win32api.GetLastInputInfo() That seems to return time stamp of last user interaction, including mouse moving, clicking, keyboard input, app switching, etc. stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: Jacob Kruger To: python-win32 at python.org Sent: Tuesday, 18 February, 2014 9:59 PM Subject: [python-win32] win32gui cursor position tracking etc. Firstly, I know the following can retrieve mouse cursor position coordinates easily enough: import win32gui tPos = win32gui.GetCursorPos() But, while something like .GetCursorInfo looks promising, I am struggling to find more info about what the first two returned items are - one of them seems to be an integer which almost matches the same value you get returned using just .GetCursor(), but, the main thing is while the mouse cursor coordinates are useful, etc., the main thing I actually want to be able to retrieve at this stage is the current position/coordinates of either the currently focused item, or the keyboard/PC cursor - as in, for example, if your mouse is hovering higher up on screen, but, lower down you're typing text in some or other text box, etc., and, primary issue is that I would prefer to just be able to track the cursor itself, since the control elements/interface the user may be involved in using will be a separate piece of software, etc. - as in, I actually want to do something more along the lines of double checking if the computer is in active use, and, while am pretty sure wouldn't be able to intercept keystrokes - don't want to- but something similar to being able to easily track position/coordinates of mouse cursor is what am trying to implement, and issue is also that for example with forms of accessibility software like my screenreader, I might at times not really use the mouse cursor for quite a while at all, since I primarily just navigate whole operating system using cursor and tab keys, along with keyboard invocation of menu systems, control shortcut keys, etc.. Suggestions? Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ------------------------------------------------------------------------------ _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Feb 19 10:18:50 2014 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 19 Feb 2014 09:18:50 +0000 Subject: [python-win32] List of keys and values In-Reply-To: References: Message-ID: <530476FA.4040804@timgolden.me.uk> On 18/02/2014 18:59, Aaron Reabow wrote: > Hi Guys, > > This should be dead simple. > > I am just trying to find a list of all of the key value pairs held for > each message. > > > These are the ones that I have found so far: > > * subject > * SenderName > * Recipients > * TaskDueDate > > I am using this simple code snippet > > import win32com.client > > outlook = > win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") > > inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a > folder - in this case, > # the inbox. You can change that > number to reference > # any other folder > messages = inbox.Items > message = messages.GetLast() > > then doing this for eample: > > > for message in messages: > print message.TaskDueDate > > > i was wondering what else I can get access to for a message? First of all, thanks for giving a self-contained code example so we know what you're seeing. Next, by way of answering your question somewhat indirectly, try this: import win32com.client app = win32com.client.gencache.EnsureDispatch("Outlook.Application") outlook = app.GetNamespace("MAPI") print(repr(outlook)) help(outlook) Because I've generated a static proxy for the underlying COM objects, you can use the standard Python introspection for a certain amount of useful information. Generally you can see the methods with their parameters. Also, though, instead of a generic "" you can see that the "outlook" object is an instance of the _Namespace class in the Outlook 12.0 object library. Even if there was nothing else you could do through Python itself, you can drop those terms into a search engine and come up with something like: http://msdn.microsoft.com/en-us/library/office/bb219955.aspx Obviously you can do the same with the messages etc. so: # carrying on from above... inbox = outlook.GetDefaultFolder(6) message = inbox.Items.GetLast() print(repr(message)) help(message) and here, the message is a MailItem instance and so we can get to here: http://msdn.microsoft.com/en-us/library/office/ff861252.aspx and so on. If you want to, you can go digging in the _prop_map_get_ attribute which is how the Python Dispatch wrapper stores its internal mappings, but it's a little involved if you're just hoping for a list of attribute names (and, especially, their meanings). TJG From timr at probo.com Wed Feb 19 19:05:54 2014 From: timr at probo.com (Tim Roberts) Date: Wed, 19 Feb 2014 10:05:54 -0800 Subject: [python-win32] win32gui cursor position tracking etc. In-Reply-To: References: Message-ID: <5304F282.10205@probo.com> Jacob Kruger wrote: > ... > But, while something like .GetCursorInfo looks promising, I am > struggling to find more info about what the first two returned items > are - one of them seems to be an integer which almost matches the same > value you get returned using just .GetCursor(), ... > > Suggestions? You always need to remember that virtually everything exposed by the PyWin32 modules are wrappers around ordinary Win32 APIs. The master reference for Win32 APIs is the MSDN library. If you had Googled for GetCursorInfo, you'd get this page: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648389.aspx which would point you to the CURSORINFO structure that has your goodies: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648381.aspx -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jacob at blindza.co.za Wed Feb 19 20:54:07 2014 From: jacob at blindza.co.za (Jacob Kruger) Date: Wed, 19 Feb 2014 21:54:07 +0200 Subject: [python-win32] win32gui cursor position tracking etc. In-Reply-To: <5304F282.10205@probo.com> References: <5304F282.10205@probo.com> Message-ID: <60D16BABED864181A6C95089C68ECCF7@JakePC> Thanks. Seems like this cursor is pretty much only referring to mouse/pointer cursor, and isn't the one I am actually interested in then - that one's most likely hidden from 'external'/other apps/software, but, at least that other workaround I found seems alright for now anyway. Stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: Tim Roberts To: Python-Win32 List Sent: Wednesday, 19 February, 2014 8:05 PM Subject: Re: [python-win32] win32gui cursor position tracking etc. Jacob Kruger wrote: ... But, while something like .GetCursorInfo looks promising, I am struggling to find more info about what the first two returned items are - one of them seems to be an integer which almost matches the same value you get returned using just .GetCursor(), ... Suggestions? You always need to remember that virtually everything exposed by the PyWin32 modules are wrappers around ordinary Win32 APIs. The master reference for Win32 APIs is the MSDN library. If you had Googled for GetCursorInfo, you'd get this page: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648389.aspx which would point you to the CURSORINFO structure that has your goodies: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648381.aspx -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. ------------------------------------------------------------------------------ _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfarrow at enthought.com Thu Feb 20 04:48:03 2014 From: cfarrow at enthought.com (Chris Farrow) Date: Wed, 19 Feb 2014 21:48:03 -0600 Subject: [python-win32] [comtypes-users] comtypes + mshtml was slow to me, any suggestion? In-Reply-To: References: Message-ID: Hi Xin, On Sat, Feb 15, 2014 at 9:32 PM, Xin Zhao wrote: > Hey, > > I am trying to build a test tool using comtypes and mshtml to handle some > applications that have IE activex control, which renders some logics > predefined in an HTML file. But I have two issues: > > > 1. I did "from comtypes.client import GetModule" and then > "GetModule('mshtml.tlb')". It took a few minutes to finish this function. > The second run was faster, but still took about 6 seconds. Is this normal? > > mshtml.tlb is huge. It is expected to take a while to generate the module the first time, though "a few minutes" seems excessive. Its sheer size is probably enough to lead to slow imports after the module is generated on the first load. > > 1. I usee comtypes to get IHTMLDocument2 interface, and then enumerate > all HTML elements in the application. But for some page, it took more than > 2 minutes to process. This seems to be way too slow. I think I must miss > something. But have no clue about it. > > How many HTML elements were being enumerated? I am not familiar with this interface, iterating over a large number of items and creating auxiliary objects, or copying basic types, can be slow. Regards, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From raghavendraprasad.nl at gmail.com Fri Feb 28 06:44:48 2014 From: raghavendraprasad.nl at gmail.com (Raghavendra Prasad NL) Date: Fri, 28 Feb 2014 13:44:48 +0800 Subject: [python-win32] Error[windows 8.1 machine]: The ordinal 782 could not be located in the dynamic link library C:\Windows\System32\urlmon.dll Message-ID: I am using pywin32-218.win32-py2.7.exe. I am getting "The ordinal 782 could not be located in the dynamic link library C:\Windows\System32\urlmon.dll" in windows 8.1 machine. This is the log I got from depends walker LoadLibraryA("urlmon.dll") called from "PYTHONCOM27.DLL" at address 0x014F1C8B by thread 1. Loaded "c:\windows\system32\URLMON.DLL" at address 0x70080000 by thread 1. Successfully hooked module. Loaded "IERTUTIL.DLL" at address 0x643B0000 by thread 1. Successfully hooked module. Loaded "WININET.DLL" at address 0x63710000 by thread 1. Successfully hooked module. First chance exception 0xC0000138 (Unknown) occurred in "c:\windows\system32\NTDLL.DLL" at address 0x77051B90 by thread 1. Unloaded "c:\windows\system32\URLMON.DLL" at address 0x70080000 by thread 1. Unloaded "WININET.DLL" at address 0x63710000 by thread 1. Unloaded "IERTUTIL.DLL" at address 0x643B0000 by thread 1. LoadLibraryA("urlmon.dll") returned NULL by thread 1. Error: The operating system cannot run %1 (182). [image: Inline image 1] [image: Inline image 2] Any pointers will be greatly appreciated...Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Windows 8.PNG Type: image/png Size: 12653 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: OrdinalNotFound.PNG Type: image/png Size: 7201 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: OrdinalNotFound.PNG Type: image/png Size: 7201 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Windows 8.PNG Type: image/png Size: 12653 bytes Desc: not available URL: From skippy.hammond at gmail.com Fri Feb 28 08:47:47 2014 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 28 Feb 2014 18:47:47 +1100 Subject: [python-win32] Error[windows 8.1 machine]: The ordinal 782 could not be located in the dynamic link library C:\Windows\System32\urlmon.dll In-Reply-To: References: Message-ID: <53103F23.8060801@gmail.com> FTR, the original poster just emailed me to say he neglected to mention this problem is with a py2exe built binary - py2exe has a known problem where it sometimes copies DLLs it shouldn't - so nothing to see here :) Mark On 28/02/2014 4:44 PM, Raghavendra Prasad NL wrote: > I am using pywin32-218.win32-py2.7.exe. I am getting "The ordinal 782 > could not be located in the dynamic link library > C:\Windows\System32\urlmon.dll" in windows 8.1 machine. This is the log > I got from depends walker > > LoadLibraryA("urlmon.dll") called from "PYTHONCOM27.DLL" at address > 0x014F1C8B by thread 1. > Loaded "c:\windows\system32\URLMON.DLL" at address 0x70080000 by thread > 1. Successfully hooked module. > Loaded "IERTUTIL.DLL" at address 0x643B0000 by thread 1. Successfully > hooked module. > Loaded "WININET.DLL" at address 0x63710000 by thread 1. Successfully > hooked module. > First chance exception 0xC0000138 (Unknown) occurred in > "c:\windows\system32\NTDLL.DLL" at address 0x77051B90 by thread 1. > Unloaded "c:\windows\system32\URLMON.DLL" at address 0x70080000 by thread 1. > Unloaded "WININET.DLL" at address 0x63710000 by thread 1. > Unloaded "IERTUTIL.DLL" at address 0x643B0000 by thread 1. > LoadLibraryA("urlmon.dll") returned NULL by thread 1. Error: The > operating system cannot run %1 (182). > > > Inline image 1 > > > Inline image 2 > > > Any pointers will be greatly appreciated...Thanks! > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > From jammer10000 at ka3nam.com Fri Feb 28 22:19:32 2014 From: jammer10000 at ka3nam.com (Joe Bennett) Date: Fri, 28 Feb 2014 15:19:32 -0600 Subject: [python-win32] win32api & win32gui help Message-ID: Hi, Looking for a good simple remedial course on getting my python script to talk to a Windows program. The author of the windows program has documented the api here: http://www.logger32.net/help/Logger32/Using%20the%20Logger32%20External%20Interface.htm I'm struggling to understand how to implement the messages with win32api/ gui... I've taken a stab at it here based on my searching the web with my first goal being that I just want to 'register' with the program and receive the response from it. So far I'm still scratching my head over this... I get a response for 'hwnd' but have not been able to get any confirmation that RegisterMessage, PostMessage and GetMessage are working, configured properly or...what... Running this all in WIN7 with ActivePython 2.6.6... import win32api import win32gui hwnd = win32gui.FindWindowEx(0, 0, 0, "Logger32") print "hwnd= ", hwnd message = win32api.RegisterWindowMessage("Logger32 3") win32api.PostMessage(hwnd,message,1,99999) test = win32gui.GetMessage(hwnd,0,0) print "GetMessage: ", test Thanks!!!! -Joe KA3NAM