From arvind.kamble at gmail.com Wed May 2 12:04:59 2012 From: arvind.kamble at gmail.com (Aravind Kamble) Date: Wed, 2 May 2012 15:34:59 +0530 Subject: [python-win32] python-win32 Digest, Vol 109, Issue 26 In-Reply-To: References: Message-ID: I was downloading .zip file not the exe installer file. It worked now. Thanks for the help. But would be still interested to download the code and experiment with it. ./Aravind On Mon, Apr 30, 2012 at 3:30 PM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Re: Win32api install problem (Mark Lawrence) > 2. Re: Win32api install problem (Tim Golden) > 3. Re: Win32api install problem (Mark Hammond) > 4. Re: Win32api install problem (Tim Golden) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 30 Apr 2012 08:41:42 +0100 > From: Mark Lawrence > To: python-win32 at python.org > Subject: Re: [python-win32] Win32api install problem > Message-ID: > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 30/04/2012 08:03, Aravind Kamble wrote: > > Hi All, > > > > I am trying to install pywin32-217 for the first time on my Windows 7 64 > > bit machine. I have following installed on my machine, > > > > Python 2.7.3 > > > MS Windows SDK for Windows 7 (7.1) > > The SDK isn't usually needed. > > > Downloaded pywin32-217 from sourceforge > > Hopefully in this case either pywin32-217.win-amd64-py2.7.exe or > pywin32-217.win32-py2.7.exe as appropriate :) See below. > > > > > > > When I run the setup.py as below > > c:\pywin32-217\python setup.py install > > I've never needed to do this. Usually you would download the > appropriate version of pywin32 as given above and It Just Works when you > install, automatically finding your version of Python from the registry. > > > > > I am getting following error > > > > Building pywin32 2.7.217.0 > > Traceback (most recent call last): > > File "setup.py", line 2428, in > > ] + > > File "setup.py", line 2224, in convert_data_files > > raise RuntimeError("No files match '%s'" % file) > > RuntimeError: No files match 'pythonwin\pywin\*.cfg' > > > > There are two .cfg files (default.cfg and IDLE.cfg) under > pythonwin\pywin\. > > > > Please help how to get rid of this error and continue with installation. > > If my comments above don't help sorry, you'll have to wait until the > smarter Windows guys pick this one up, doesn't normally take too long :) > > > > > > > Regards > > Aravind > > > > > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > -- > Cheers. > > Mark Lawrence. > > > > ------------------------------ > > Message: 2 > Date: Mon, 30 Apr 2012 08:42:06 +0100 > From: Tim Golden > Cc: python-win32 at python.org > Subject: Re: [python-win32] Win32api install problem > Message-ID: <4F9E424E.5020600 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1 > > On 30/04/2012 08:03, Aravind Kamble wrote: > > Hi All, > > > > I am trying to install pywin32-217 for the first time on my Windows 7 64 > > bit machine. I have following installed on my machine, > > > > Python 2.7.3 > > MS Windows SDK for Windows 7 (7.1) > > Downloaded pywin32-217 from sourceforge > > > > > > When I run the setup.py as below > > c:\pywin32-217\python setup.py install > > > > I am getting following error > > > > Building pywin32 2.7.217.0 > > Traceback (most recent call last): > > File "setup.py", line 2428, in > > ] + > > File "setup.py", line 2224, in convert_data_files > > raise RuntimeError("No files match '%s'" % file) > > RuntimeError: No files match 'pythonwin\pywin\*.cfg' > > > > There are two .cfg files (default.cfg and IDLE.cfg) under > pythonwin\pywin\. > > > > Please help how to get rid of this error and continue with installation. > > Do you have / want to build from source? If not, download one > of the binaries from Sourceforge and use that. If you do need > to build from source, you'll have to patch the setup.py in > the pywin32 sourceball to add a parameter anchor=0 to the calls > to include_pattern and exclude_pattern within the convert_data_files > function. > > (I was just about to get in touch with Mark H and offer a patch but > I won't have time to do the mechanics until this afternoon at the > earliest...) > > FWIW this is due to a recent-ish change to distutils which fixed a > longstanding bugette. The effect was to tighten up the action of > include|exclude_pattern calls so that they don't match against > directory strings unless anchor is set to 0. > > Again, though, unless you *want* to build from source, you can just > download a binary build. > > > TJG > > > ------------------------------ > > Message: 3 > Date: Mon, 30 Apr 2012 17:50:52 +1000 > From: Mark Hammond > To: Tim Golden > Cc: python-win32 at python.org > Subject: Re: [python-win32] Win32api install problem > Message-ID: <4F9E445C.1020307 at gmail.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 30/04/2012 5:42 PM, Tim Golden wrote: > > On 30/04/2012 08:03, Aravind Kamble wrote: > >> Hi All, > >> > >> I am trying to install pywin32-217 for the first time on my Windows 7 64 > >> bit machine. I have following installed on my machine, > >> > >> Python 2.7.3 > >> MS Windows SDK for Windows 7 (7.1) > >> Downloaded pywin32-217 from sourceforge > >> > >> > >> When I run the setup.py as below > >> c:\pywin32-217\python setup.py install > >> > >> I am getting following error > >> > >> Building pywin32 2.7.217.0 > >> Traceback (most recent call last): > >> File "setup.py", line 2428, in > >> ] + > >> File "setup.py", line 2224, in convert_data_files > >> raise RuntimeError("No files match '%s'" % file) > >> RuntimeError: No files match 'pythonwin\pywin\*.cfg' > >> > >> There are two .cfg files (default.cfg and IDLE.cfg) under > pythonwin\pywin\. > >> > >> Please help how to get rid of this error and continue with installation. > > > > Do you have / want to build from source? If not, download one > > of the binaries from Sourceforge and use that. If you do need > > to build from source, you'll have to patch the setup.py in > > the pywin32 sourceball to add a parameter anchor=0 to the calls > > to include_pattern and exclude_pattern within the convert_data_files > > function. > > > > (I was just about to get in touch with Mark H and offer a patch but > > I won't have time to do the mechanics until this afternoon at the > > earliest...) > > Thanks for the clue - I just updated Python 2.7 from hg, verified the > bug and also verified your fix seems to work. I've checked it in and > pushed it. > > Thanks! > > Mark > > > > FWIW this is due to a recent-ish change to distutils which fixed a > > longstanding bugette. The effect was to tighten up the action of > > include|exclude_pattern calls so that they don't match against > > directory strings unless anchor is set to 0. > > > > Again, though, unless you *want* to build from source, you can just > > download a binary build. > > > > > > TJG > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > ------------------------------ > > Message: 4 > Date: Mon, 30 Apr 2012 08:56:22 +0100 > From: Tim Golden > To: mhammond at skippinet.com.au > Cc: python-win32 at python.org > Subject: Re: [python-win32] Win32api install problem > Message-ID: <4F9E45A6.2000906 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1 > > On 30/04/2012 08:50, Mark Hammond wrote: > > On 30/04/2012 5:42 PM, Tim Golden wrote: > >> (I was just about to get in touch with Mark H and offer a patch but > >> I won't have time to do the mechanics until this afternoon at the > >> earliest...) > > > > Thanks for the clue - I just updated Python 2.7 from hg, verified the > > bug and also verified your fix seems to work. I've checked it in and > > pushed it. > > Thanks for the quick turnaround. FWIW there appear to be other issues > against Python trunk due to the *very* recent importlib changes. Before > I dive in: are you able to build & install against Python's hg tip? > > I was getting an importlib error when trying to import pywintypes. > I'll try to get a build environment up here (at work) to make sure > I can reproduce. > > > TJG > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 109, Issue 26 > ********************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arvind.kamble at gmail.com Wed May 2 14:25:34 2012 From: arvind.kamble at gmail.com (Aravind Kamble) Date: Wed, 2 May 2012 17:55:34 +0530 Subject: [python-win32] File name and version as dictionary key value Message-ID: Hi All, Hope I am posting in correct mailing list. Am facing another problem now. My logic is to get file versions of files inside two directories and compare them. I am trying to get filename and version as key, value pairs in a directory. I have a function written which will provide me the file version. I have file names in a list. I am not able to populate my directory with filename and version. Code snippet looks something like this, Filename_Version_dir={} from filename in filename_version_list: # I want to populate my directory here with filename and version given by the function get_file_version(filename) # I want something like Filename_Version_dir.append(filename:get_file_version) What is the best thing I can do here? Thanks in advance, ./Aravind -------------- next part -------------- An HTML attachment was scrubbed... URL: From kris at rhs.com Wed May 2 14:30:54 2012 From: kris at rhs.com (Kris Hardy) Date: Wed, 02 May 2012 08:30:54 -0400 Subject: [python-win32] File name and version as dictionary key value In-Reply-To: References: Message-ID: <4FA128FE.9080905@rhs.com> On 5/2/2012 8:25 AM, Aravind Kamble wrote: > Hi All, > > Hope I am posting in correct mailing list. Am facing another problem > now. My logic is to get file versions of files inside two directories > and compare them. I am trying to get filename and version as key, > value pairs in a directory. I have a function written which will > provide me the file version. I have file names in a list. I am not > able to populate my directory with filename and version. Code snippet > looks something like this, > > Filename_Version_dir={} > > from filename in filename_version_list: > # I want to populate my directory here with filename and > version given by the function get_file_version(filename) > # I want something like > Filename_Version_dir.append(filename:get_file_version) Filename_Version_dir[filename] = get_file_version(filename) > > > What is the best thing I can do here? > > Thanks in advance, > > > > ./Aravind > > > > > _______________________________________________ > 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 max at slimmersoft.com Wed May 2 18:05:26 2012 From: max at slimmersoft.com (Max Slimmer) Date: Wed, 2 May 2012 09:05:26 -0700 Subject: [python-win32] File name and version as dictionary key value In-Reply-To: References: Message-ID: Filename_version_dir = dir([(nam,filename:get_file_version(nam)) for nam in filename_version_list]) This is a list comprehension which returns a list of (name,ver). You should look at http://docs.python.org/library/stdtypes.html# and pay attention to lists and mapping types (dict) and all the things you can do with them. You should also go through the tutorial it doesn't take much time and will give you a good foundation. the append() method is for lists not dicts the for construct is the primary looping tool, the reserved word from is used in import statments. On Wed, May 2, 2012 at 5:25 AM, Aravind Kamble wrote: > Hi All, > > Hope I am posting in correct mailing list.?Am facing another problem now. My > logic is to get file versions of files inside two directories and compare > them. I am trying to get filename and version as key, value pairs in a > directory. I have a function written which will provide me the file version. > I have file names in a list. I am not able to populate my directory with > filename and version. Code snippet looks something like this, > > Filename_Version_dir={} > > from filename in filename_version_list: > ? ? ? ? ? ? # I want to populate my directory here with filename and version > given by the function get_file_version(filename) > ? ? ? ? ? ?# I want something like > Filename_Version_dir.append(filename:get_file_version) > > > What is the best thing I can do here? > > Thanks in advance, > > > > ./Aravind > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From aellis02 at fs.fed.us Thu May 3 17:27:26 2012 From: aellis02 at fs.fed.us (Ellis, Alexis -FS) Date: Thu, 3 May 2012 15:27:26 +0000 Subject: [python-win32] Accessing methods from python-based COM DLL generated using py2exe Message-ID: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net> Hi All, I am trying to generate a DLL from a python script that can be accessed from a variety other programming platforms. I am generating the python-based COM DLL using a distutils setup script that is called using py2exe. The DLL is successfully generated and I can register it using regsvr32, but now I am not sure how to access the function within the dll. This is a test scenario but ideally I will have multiple functions in my python script that will need to be called and to which I will need to pass arguments. In order to test this process I created a simple python script: testscript.py ///////////////////////// class testscript: def tryit(a,b): alexis = a + b return alexis ///////////////////////// I then ran the following setup script from command line>> setup.py py2exe setup.py ///////////////////////// from distutils.core import setup import py2exe import sys import comtypes import comtypes.client class Target: def __init__(self, **kw): self.__dict__.update(kw) # for the version info resources (Properties -- Version) self.version = "0.0.1" self.company_name = "my company" self.copyright = "(c) 2006, my company" self.name = "my com server name" my_com_server_target = Target( description = "my com server", # use module name for ctypes.com dll server modules = ["testscript"], # we only want the inproc (dll) server create_exe = False create_dll = True ) setup( name="my_com_server", # the following two parameters embed support files within dll file options={"py2exe": {"bundle_files": 1, }}, zipfile=None, version="0.0.1", description="my com server", # author, maintainer, contact go here: author="First Last", author_email="some_name at some_company.com", ctypes_com_server=[my_com_server_target] ) ////////////////////////////////////// >From command line I run>> regsvr32 testscript.dll The dll is successfully registered. I am assuming that I now have a COM DLL that I can test in python using win32com, but I am not sure how to go about doing this. Any help would be greatly appreciated! Thanks, Alexis [cid:image001.gif at 01CD2915.42AE8CC0] This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 1488 bytes Desc: image001.gif URL: From biotech at gmail.com Thu May 3 17:42:07 2012 From: biotech at gmail.com (Tim Keeler) Date: Thu, 3 May 2012 08:42:07 -0700 Subject: [python-win32] win32evtlog - Event Log parsing issue Message-ID: Hello, I'm having a problem with win32evtlog and reading events from an event log channel on Windows Server 2008 R2. I'm using the following code and get the following error (python.exe APPCRASH no exceptions): #!/usr/bin/python # Windows Event Log Viewer import win32evtlog # requires pywin32 pre-installed hand = win32evtlog.EvtOpenLog('ForwardedEvents',1,None) flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ *events = win32evtlog.ReadEventLog(hand, flags, 0)* The last line calling ReadEventLog() is what causes the crash. I had to read through the source code to find the function EvtOpenLog() for channel support, this isn't in the latest documentation. So I'm not sure if this is still experimental or not. Any help or guidance would be greatly appreciated. I'm using Python 2.7.3 Problem signature: Problem Event Name: APPCRASH Application Name: python.exe Application Version: 0.0.0.0 Application Timestamp: 4f84a6c8 Fault Module Name: ADVAPI32.dll Fault Module Version: 6.1.7600.16385 Fault Module Timestamp: 4a5bd97e Exception Code: c0000005 Exception Offset: 00019347 OS Version: 6.1.7600.2.0.0.274.10 Locale ID: 1033 Additional Information 1: 0a9e Additional Information 2: 0a9e372d3b4ad19135b953a78882e789 Additional Information 3: 0a9e Additional Information 4: 0a9e372d3b4ad19135b953a78882e789 Read our privacy statement online: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409 If the online privacy statement is not available, please read our privacy statement offline: C:\Windows\system32\en-US\erofflps.txt -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu May 3 19:19:48 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 3 May 2012 10:19:48 -0700 Subject: [python-win32] Accessing methods from python-based COM DLL generated using py2exe In-Reply-To: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net> References: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net> Message-ID: <4FA2BE34.80000@probo.com> Ellis, Alexis -FS wrote: > > > > am trying to generate a DLL from a python script that can be accessed > from a variety other programming platforms. > > I am generating the python-based COM DLL using a distutils setup > script that is called using py2exe. > > The DLL is successfully generated and I can register it using > regsvr32, but now I am not sure how to access the function within the dll. > Well, you have not actually created a COM server here. What you have registered is an empty COM server that defines no methods. You haven't actually used any methods from comtypes or comtypes.client at all. You need to read the documentation for comtypes.server. You have to create an IDL file (Interface Description Language) that defines the methods you expect to expose. You compile that IDL to a type library (TLB). Then, you use comtypes.client.GetModule to generate a wrapper for that IDL. Then, your "testscript" module must derive from that class, and implement the methods you declared. comtypes creates an "early binding" COM server. Depending on the languages you want to use, you might find it easier to create a "late binding" server using Pythoncom, as described here: http://showmedo.com/videotutorials/video?name=2190050&fromSeriesID=219 No IDL is required with this method. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Fri May 4 01:35:26 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 04 May 2012 09:35:26 +1000 Subject: [python-win32] win32evtlog - Event Log parsing issue In-Reply-To: References: Message-ID: <4FA3163E.6010206@gmail.com> I'm afraid I'm not familiar with that API, but the crash is because EvtOpenLog is returning a handle with a value of 1 and ReadEventLog is crashing with that handle. A quick google doesn't find anyone trying to use ReadEventLog with a handle returned by EvtOpenLog but instead uses EvtGetLogInfo. Roger Upole added support for these functions so hopefully he is reading this and has more experience with the API (and the fact they aren't in the generated docs should indeed be treated as a bug!) Mark On 4/05/2012 1:42 AM, Tim Keeler wrote: > Hello, > > I'm having a problem with win32evtlog and reading events from an event > log channel on Windows Server 2008 R2. I'm using the following code and > get the following error (python.exe APPCRASH no exceptions): > > #!/usr/bin/python > > # Windows Event Log Viewer > import win32evtlog # requires pywin32 pre-installed > > hand = win32evtlog.EvtOpenLog('ForwardedEvents',1,None) > flags = > win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ > > *events = win32evtlog.ReadEventLog(hand, flags, 0)* > > > The last line calling ReadEventLog() is what causes the crash. I had to > read through the source code to find the function EvtOpenLog() for > channel support, this isn't in the latest documentation. So I'm not sure > if this is still experimental or not. > > Any help or guidance would be greatly appreciated. I'm using Python 2.7.3 > > Problem signature: > Problem Event Name:APPCRASH > Application Name:python.exe > Application Version:0.0.0.0 > Application Timestamp:4f84a6c8 > Fault Module Name:ADVAPI32.dll > Fault Module Version:6.1.7600.16385 > Fault Module Timestamp:4a5bd97e > Exception Code:c0000005 > Exception Offset:00019347 > OS Version:6.1.7600.2.0.0.274.10 > Locale ID:1033 > Additional Information 1:0a9e > Additional Information 2:0a9e372d3b4ad19135b953a78882e789 > Additional Information 3:0a9e > Additional Information 4:0a9e372d3b4ad19135b953a78882e789 > > Read our privacy statement online: > http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409 > > If the online privacy statement is not available, please read our > privacy statement offline: > C:\Windows\system32\en-US\erofflps.txt > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From biotech at gmail.com Fri May 4 02:09:03 2012 From: biotech at gmail.com (Tim Keeler) Date: Thu, 3 May 2012 17:09:03 -0700 Subject: [python-win32] win32evtlog - Event Log parsing issue In-Reply-To: <4FA3163E.6010206@gmail.com> References: <4FA3163E.6010206@gmail.com> Message-ID: Thanks for the reply, Mark! I took a look and didn't see the EvtGetLogInfo() implemented anywhere in the source. Hopefully Roger will be able to figure out what's going on here. -Tim On Thu, May 3, 2012 at 4:35 PM, Mark Hammond wrote: > I'm afraid I'm not familiar with that API, but the crash is because > EvtOpenLog is returning a handle with a value of 1 and ReadEventLog is > crashing with that handle. A quick google doesn't find anyone trying to > use ReadEventLog with a handle returned by EvtOpenLog but instead uses > EvtGetLogInfo. > > Roger Upole added support for these functions so hopefully he is reading > this and has more experience with the API (and the fact they aren't in the > generated docs should indeed be treated as a bug!) > > Mark > > > On 4/05/2012 1:42 AM, Tim Keeler wrote: > >> Hello, >> >> I'm having a problem with win32evtlog and reading events from an event >> log channel on Windows Server 2008 R2. I'm using the following code and >> get the following error (python.exe APPCRASH no exceptions): >> >> #!/usr/bin/python >> >> # Windows Event Log Viewer >> import win32evtlog # requires pywin32 pre-installed >> >> hand = win32evtlog.EvtOpenLog('**ForwardedEvents',1,None) >> flags = >> win32evtlog.EVENTLOG_**BACKWARDS_READ|win32evtlog.** >> EVENTLOG_SEQUENTIAL_READ >> >> *events = win32evtlog.ReadEventLog(hand, flags, 0)* >> >> >> >> The last line calling ReadEventLog() is what causes the crash. I had to >> read through the source code to find the function EvtOpenLog() for >> channel support, this isn't in the latest documentation. So I'm not sure >> if this is still experimental or not. >> >> Any help or guidance would be greatly appreciated. I'm using Python 2.7.3 >> >> Problem signature: >> Problem Event Name:APPCRASH >> Application Name:python.exe >> Application Version:0.0.0.0 >> Application Timestamp:4f84a6c8 >> Fault Module Name:ADVAPI32.dll >> Fault Module Version:6.1.7600.16385 >> Fault Module Timestamp:4a5bd97e >> Exception Code:c0000005 >> Exception Offset:00019347 >> OS Version:6.1.7600.2.0.0.274.10 >> Locale ID:1033 >> Additional Information 1:0a9e >> Additional Information 2:**0a9e372d3b4ad19135b953a78882e7**89 >> Additional Information 3:0a9e >> Additional Information 4:**0a9e372d3b4ad19135b953a78882e7**89 >> >> Read our privacy statement online: >> http://go.microsoft.com/**fwlink/?linkid=104288&clcid=**0x0409 >> >> If the online privacy statement is not available, please read our >> privacy statement offline: >> C:\Windows\system32\en-US\**erofflps.txt >> >> >> >> >> ______________________________**_________________ >> 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 rupole at hotmail.com Fri May 4 05:47:09 2012 From: rupole at hotmail.com (Roger Upole) Date: Thu, 3 May 2012 23:47:09 -0400 Subject: [python-win32] win32evtlog - Event Log parsing issue References: <4FA3163E.6010206@gmail.com> Message-ID: Mark is right, the handles are not interchangable between the older event log functions and the newer Evt* functions. You can still use the older APIs on Vista and later, though. OpenEventLog returns a handle compatible with ReadEventLog. To use the newer functions, try EvtQuery->EvtNext->EvtRender. Regarding the docs, the Evt* functions appear in the latest .chm help file. Which documentation are you looking at ? Roger "Tim Keeler" wrote in message news:CAJpmmnW0T1SZVkYqcvsGsnritencuQYszD0KGNx8sKPnD+Rwbg at mail.gmail.com... > Thanks for the reply, Mark! > > I took a look and didn't see the EvtGetLogInfo() implemented anywhere in > the source. Hopefully Roger will be able to figure out what's going on here. > > -Tim > > On Thu, May 3, 2012 at 4:35 PM, Mark Hammond wrote: > >> I'm afraid I'm not familiar with that API, but the crash is because >> EvtOpenLog is returning a handle with a value of 1 and ReadEventLog is >> crashing with that handle. A quick google doesn't find anyone trying to >> use ReadEventLog with a handle returned by EvtOpenLog but instead uses >> EvtGetLogInfo. >> >> Roger Upole added support for these functions so hopefully he is reading >> this and has more experience with the API (and the fact they aren't in the >> generated docs should indeed be treated as a bug!) >> >> Mark >> >> >> On 4/05/2012 1:42 AM, Tim Keeler wrote: >> >>> Hello, >>> >>> I'm having a problem with win32evtlog and reading events from an event >>> log channel on Windows Server 2008 R2. I'm using the following code and >>> get the following error (python.exe APPCRASH no exceptions): >>> >>> #!/usr/bin/python >>> >>> # Windows Event Log Viewer >>> import win32evtlog # requires pywin32 pre-installed >>> >>> hand = win32evtlog.EvtOpenLog('**ForwardedEvents',1,None) >>> flags = >>> win32evtlog.EVENTLOG_**BACKWARDS_READ|win32evtlog.** >>> EVENTLOG_SEQUENTIAL_READ >>> >>> *events = win32evtlog.ReadEventLog(hand, flags, 0)* >>> >>> >>> >>> The last line calling ReadEventLog() is what causes the crash. I had to >>> read through the source code to find the function EvtOpenLog() for >>> channel support, this isn't in the latest documentation. So I'm not sure >>> if this is still experimental or not. >>> >>> Any help or guidance would be greatly appreciated. I'm using Python 2.7.3 >>> >>> Problem signature: >>> Problem Event Name:APPCRASH >>> Application Name:python.exe >>> Application Version:0.0.0.0 >>> Application Timestamp:4f84a6c8 >>> Fault Module Name:ADVAPI32.dll >>> Fault Module Version:6.1.7600.16385 >>> Fault Module Timestamp:4a5bd97e >>> Exception Code:c0000005 >>> Exception Offset:00019347 >>> OS Version:6.1.7600.2.0.0.274.10 >>> Locale ID:1033 >>> Additional Information 1:0a9e >>> Additional Information 2:**0a9e372d3b4ad19135b953a78882e7**89 >>> Additional Information 3:0a9e >>> Additional Information 4:**0a9e372d3b4ad19135b953a78882e7**89 >>> >>> Read our privacy statement online: >>> http://go.microsoft.com/**fwlink/?linkid=104288&clcid=**0x0409 >>> >>> If the online privacy statement is not available, please read our >>> privacy statement offline: >>> C:\Windows\system32\en-US\**erofflps.txt >>> >>> >>> >>> >>> ______________________________**_________________ >>> 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 aellis02 at syr.edu Fri May 4 17:07:13 2012 From: aellis02 at syr.edu (Alexis Ellis) Date: Fri, 4 May 2012 15:07:13 +0000 Subject: [python-win32] Accessing methods from python-based COM DLL generated using py2exe In-Reply-To: <4FA2BE34.80000@probo.com> References: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net>, <4FA2BE34.80000@probo.com> Message-ID: Tim, Thank you for your help. I was obviously headed down the wrong path. As per your suggestion, I am now using comtypes to create a com server. I have generated a tlb and am trying to use comtypes.client.GetModule to generate a wrapper and register the COM (see myserver.py below). However, when I try do to this using the following command: >>python myserver.py /regserver I get the following error: Traceback (most recent call last): File "myserver.py", line 23, in import win32com.server.register File "c:\python26\arcgis10.0\lib\site-packages\win32com\server\register.py", l ine 13, in import winerror File "c:\python26\arcgis10.0\winerror.py", line 3, in from nterror import * File "c:\python26\arcgis10.0\nterror.py", line 4, in import windll File "c:\python26\arcgis10.0\windll.py", line 20, in import calldll ImportError: No module named calldll I do not have a module named calldll and can not find one online (other than for python2.4 - I am using 2.6.5). Not sure how to address this. Any help would be greatly appreciated! Thanks, Alexis The following is my wrapper/registration code: myserver.py ///////////////////////////////// import comtypes import comtypes.server.localserver from comtypes.client import GetModule # generate wrapper code for the type library, this needs # to be done only once (but also each time the IDL file changes) GetModule("comcreate.tlb") from comtypes.gen.MyTypeLib import MyObject class MyObjectImpl(MyObject): # registry entries _reg_threading_ = "Both" _reg_progid_ = "MyTypeLib.MyObject.1" _reg_novers_progid_ = "MyTypeLib.MyObject" _reg_desc_ = "Simple COM server for testing" _reg_clsctx_ = comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER _regcls_ = comtypes.server.localserver.REGCLS_MULTIPLEUSE #register is a module-level function def register(): import win32com.server.register win32com.server.register.UseCommandLine(MyObjectImpl) if __name__ == "__main__": register() ////////////////////////////////////////////// ________________________________________ From: python-win32-bounces+aellis02=syr.edu at python.org [python-win32-bounces+aellis02=syr.edu at python.org] on behalf of Tim Roberts [timr at probo.com] Sent: Thursday, May 03, 2012 1:19 PM To: Python-Win32 List Subject: Re: [python-win32] Accessing methods from python-based COM DLL generated using py2exe Ellis, Alexis -FS wrote: > > > > am trying to generate a DLL from a python script that can be accessed > from a variety other programming platforms. > > I am generating the python-based COM DLL using a distutils setup > script that is called using py2exe. > > The DLL is successfully generated and I can register it using > regsvr32, but now I am not sure how to access the function within the dll. > Well, you have not actually created a COM server here. What you have registered is an empty COM server that defines no methods. You haven't actually used any methods from comtypes or comtypes.client at all. You need to read the documentation for comtypes.server. You have to create an IDL file (Interface Description Language) that defines the methods you expect to expose. You compile that IDL to a type library (TLB). Then, you use comtypes.client.GetModule to generate a wrapper for that IDL. Then, your "testscript" module must derive from that class, and implement the methods you declared. comtypes creates an "early binding" COM server. Depending on the languages you want to use, you might find it easier to create a "late binding" server using Pythoncom, as described here: http://showmedo.com/videotutorials/video?name=2190050&fromSeriesID=219 No IDL is required with this method. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From aellis02 at syr.edu Fri May 4 17:13:00 2012 From: aellis02 at syr.edu (Alexis Ellis) Date: Fri, 4 May 2012 15:13:00 +0000 Subject: [python-win32] Accessing methods from python-based COM DLL generated using py2exe In-Reply-To: References: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net>, <4FA2BE34.80000@probo.com>, Message-ID: As a note, I have read that I should be using ctypes instead of calldll, but am not sure how to implement that change. ________________________________________ From: python-win32-bounces+aellis02=syr.edu at python.org [python-win32-bounces+aellis02=syr.edu at python.org] on behalf of Alexis Ellis [aellis02 at syr.edu] Sent: Friday, May 04, 2012 11:07 AM To: Tim Roberts; Python-Win32 List Subject: Re: [python-win32] Accessing methods from python-based COM DLL generated using py2exe Tim, Thank you for your help. I was obviously headed down the wrong path. As per your suggestion, I am now using comtypes to create a com server. I have generated a tlb and am trying to use comtypes.client.GetModule to generate a wrapper and register the COM (see myserver.py below). However, when I try do to this using the following command: >>python myserver.py /regserver I get the following error: Traceback (most recent call last): File "myserver.py", line 23, in import win32com.server.register File "c:\python26\arcgis10.0\lib\site-packages\win32com\server\register.py", l ine 13, in import winerror File "c:\python26\arcgis10.0\winerror.py", line 3, in from nterror import * File "c:\python26\arcgis10.0\nterror.py", line 4, in import windll File "c:\python26\arcgis10.0\windll.py", line 20, in import calldll ImportError: No module named calldll I do not have a module named calldll and can not find one online (other than for python2.4 - I am using 2.6.5). Not sure how to address this. Any help would be greatly appreciated! Thanks, Alexis The following is my wrapper/registration code: myserver.py ///////////////////////////////// import comtypes import comtypes.server.localserver from comtypes.client import GetModule # generate wrapper code for the type library, this needs # to be done only once (but also each time the IDL file changes) GetModule("comcreate.tlb") from comtypes.gen.MyTypeLib import MyObject class MyObjectImpl(MyObject): # registry entries _reg_threading_ = "Both" _reg_progid_ = "MyTypeLib.MyObject.1" _reg_novers_progid_ = "MyTypeLib.MyObject" _reg_desc_ = "Simple COM server for testing" _reg_clsctx_ = comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER _regcls_ = comtypes.server.localserver.REGCLS_MULTIPLEUSE #register is a module-level function def register(): import win32com.server.register win32com.server.register.UseCommandLine(MyObjectImpl) if __name__ == "__main__": register() ////////////////////////////////////////////// ________________________________________ From: python-win32-bounces+aellis02=syr.edu at python.org [python-win32-bounces+aellis02=syr.edu at python.org] on behalf of Tim Roberts [timr at probo.com] Sent: Thursday, May 03, 2012 1:19 PM To: Python-Win32 List Subject: Re: [python-win32] Accessing methods from python-based COM DLL generated using py2exe Ellis, Alexis -FS wrote: > > > > am trying to generate a DLL from a python script that can be accessed > from a variety other programming platforms. > > I am generating the python-based COM DLL using a distutils setup > script that is called using py2exe. > > The DLL is successfully generated and I can register it using > regsvr32, but now I am not sure how to access the function within the dll. > Well, you have not actually created a COM server here. What you have registered is an empty COM server that defines no methods. You haven't actually used any methods from comtypes or comtypes.client at all. You need to read the documentation for comtypes.server. You have to create an IDL file (Interface Description Language) that defines the methods you expect to expose. You compile that IDL to a type library (TLB). Then, you use comtypes.client.GetModule to generate a wrapper for that IDL. Then, your "testscript" module must derive from that class, and implement the methods you declared. comtypes creates an "early binding" COM server. Depending on the languages you want to use, you might find it easier to create a "late binding" server using Pythoncom, as described here: http://showmedo.com/videotutorials/video?name=2190050&fromSeriesID=219 No IDL is required with this method. -- 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 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From aellis02 at syr.edu Fri May 4 17:52:29 2012 From: aellis02 at syr.edu (Alexis Ellis) Date: Fri, 4 May 2012 15:52:29 +0000 Subject: [python-win32] Accessing methods from python-based COM DLL generated using py2exe In-Reply-To: References: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net>, <4FA2BE34.80000@probo.com>, , Message-ID: Ignore my previous question. I replaced calldll with ctypes in the windll.py and everything now seems to be working. ________________________________________ From: python-win32-bounces+aellis02=syr.edu at python.org [python-win32-bounces+aellis02=syr.edu at python.org] on behalf of Alexis Ellis [aellis02 at syr.edu] Sent: Friday, May 04, 2012 11:13 AM To: Tim Roberts; Python-Win32 List Subject: Re: [python-win32] Accessing methods from python-based COM DLL generated using py2exe As a note, I have read that I should be using ctypes instead of calldll, but am not sure how to implement that change. ________________________________________ From: python-win32-bounces+aellis02=syr.edu at python.org [python-win32-bounces+aellis02=syr.edu at python.org] on behalf of Alexis Ellis [aellis02 at syr.edu] Sent: Friday, May 04, 2012 11:07 AM To: Tim Roberts; Python-Win32 List Subject: Re: [python-win32] Accessing methods from python-based COM DLL generated using py2exe Tim, Thank you for your help. I was obviously headed down the wrong path. As per your suggestion, I am now using comtypes to create a com server. I have generated a tlb and am trying to use comtypes.client.GetModule to generate a wrapper and register the COM (see myserver.py below). However, when I try do to this using the following command: >>python myserver.py /regserver I get the following error: Traceback (most recent call last): File "myserver.py", line 23, in import win32com.server.register File "c:\python26\arcgis10.0\lib\site-packages\win32com\server\register.py", l ine 13, in import winerror File "c:\python26\arcgis10.0\winerror.py", line 3, in from nterror import * File "c:\python26\arcgis10.0\nterror.py", line 4, in import windll File "c:\python26\arcgis10.0\windll.py", line 20, in import calldll ImportError: No module named calldll I do not have a module named calldll and can not find one online (other than for python2.4 - I am using 2.6.5). Not sure how to address this. Any help would be greatly appreciated! Thanks, Alexis The following is my wrapper/registration code: myserver.py ///////////////////////////////// import comtypes import comtypes.server.localserver from comtypes.client import GetModule # generate wrapper code for the type library, this needs # to be done only once (but also each time the IDL file changes) GetModule("comcreate.tlb") from comtypes.gen.MyTypeLib import MyObject class MyObjectImpl(MyObject): # registry entries _reg_threading_ = "Both" _reg_progid_ = "MyTypeLib.MyObject.1" _reg_novers_progid_ = "MyTypeLib.MyObject" _reg_desc_ = "Simple COM server for testing" _reg_clsctx_ = comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER _regcls_ = comtypes.server.localserver.REGCLS_MULTIPLEUSE #register is a module-level function def register(): import win32com.server.register win32com.server.register.UseCommandLine(MyObjectImpl) if __name__ == "__main__": register() ////////////////////////////////////////////// ________________________________________ From: python-win32-bounces+aellis02=syr.edu at python.org [python-win32-bounces+aellis02=syr.edu at python.org] on behalf of Tim Roberts [timr at probo.com] Sent: Thursday, May 03, 2012 1:19 PM To: Python-Win32 List Subject: Re: [python-win32] Accessing methods from python-based COM DLL generated using py2exe Ellis, Alexis -FS wrote: > > > > am trying to generate a DLL from a python script that can be accessed > from a variety other programming platforms. > > I am generating the python-based COM DLL using a distutils setup > script that is called using py2exe. > > The DLL is successfully generated and I can register it using > regsvr32, but now I am not sure how to access the function within the dll. > Well, you have not actually created a COM server here. What you have registered is an empty COM server that defines no methods. You haven't actually used any methods from comtypes or comtypes.client at all. You need to read the documentation for comtypes.server. You have to create an IDL file (Interface Description Language) that defines the methods you expect to expose. You compile that IDL to a type library (TLB). Then, you use comtypes.client.GetModule to generate a wrapper for that IDL. Then, your "testscript" module must derive from that class, and implement the methods you declared. comtypes creates an "early binding" COM server. Depending on the languages you want to use, you might find it easier to create a "late binding" server using Pythoncom, as described here: http://showmedo.com/videotutorials/video?name=2190050&fromSeriesID=219 No IDL is required with this method. -- 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 _______________________________________________ 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 biotech at gmail.com Fri May 4 18:29:14 2012 From: biotech at gmail.com (Tim Keeler) Date: Fri, 4 May 2012 09:29:14 -0700 Subject: [python-win32] win32evtlog - Event Log parsing issue In-Reply-To: References: <4FA3163E.6010206@gmail.com> Message-ID: Oh Geesh - I didn't even think about looking at the .chm help file. I was looking at the docs located here - http://docs.activestate.com/activepython/2.7/pywin32/win32evtlog.html. This is my first time using Python on Windows, so I apologize for the n00b mistake. I'll check out EvtQuery->EvtNext->EvtRender, I think this is exactly what I need! Thank you for all of your help. -Tim On Thu, May 3, 2012 at 8:47 PM, Roger Upole wrote: > Mark is right, the handles are not interchangable between the older event > log functions and the newer Evt* functions. You can still use the older > APIs on Vista and later, though. OpenEventLog returns a handle > compatible with ReadEventLog. > To use the newer functions, try EvtQuery->EvtNext->EvtRender. > > Regarding the docs, the Evt* functions appear in the latest .chm help file. > Which documentation are you looking at ? > > Roger > > "Tim Keeler" wrote in message > news:CAJpmmnW0T1SZVkYqcvsGsnritencuQYszD0KGNx8sKPnD+Rwbg at mail.gmail.com... > > Thanks for the reply, Mark! > > > > I took a look and didn't see the EvtGetLogInfo() implemented anywhere in > > the source. Hopefully Roger will be able to figure out what's going on > here. > > > > -Tim > > > > On Thu, May 3, 2012 at 4:35 PM, Mark Hammond >wrote: > > > >> I'm afraid I'm not familiar with that API, but the crash is because > >> EvtOpenLog is returning a handle with a value of 1 and ReadEventLog is > >> crashing with that handle. A quick google doesn't find anyone trying to > >> use ReadEventLog with a handle returned by EvtOpenLog but instead uses > >> EvtGetLogInfo. > >> > >> Roger Upole added support for these functions so hopefully he is reading > >> this and has more experience with the API (and the fact they aren't in > the > >> generated docs should indeed be treated as a bug!) > >> > >> Mark > >> > >> > >> On 4/05/2012 1:42 AM, Tim Keeler wrote: > >> > >>> Hello, > >>> > >>> I'm having a problem with win32evtlog and reading events from an event > >>> log channel on Windows Server 2008 R2. I'm using the following code and > >>> get the following error (python.exe APPCRASH no exceptions): > >>> > >>> #!/usr/bin/python > >>> > >>> # Windows Event Log Viewer > >>> import win32evtlog # requires pywin32 pre-installed > >>> > >>> hand = win32evtlog.EvtOpenLog('**ForwardedEvents',1,None) > >>> flags = > >>> win32evtlog.EVENTLOG_**BACKWARDS_READ|win32evtlog.** > >>> EVENTLOG_SEQUENTIAL_READ > >>> > >>> *events = win32evtlog.ReadEventLog(hand, flags, 0)* > >>> > >>> > >>> > >>> The last line calling ReadEventLog() is what causes the crash. I had to > >>> read through the source code to find the function EvtOpenLog() for > >>> channel support, this isn't in the latest documentation. So I'm not > sure > >>> if this is still experimental or not. > >>> > >>> Any help or guidance would be greatly appreciated. I'm using Python > 2.7.3 > >>> > >>> Problem signature: > >>> Problem Event Name:APPCRASH > >>> Application Name:python.exe > >>> Application Version:0.0.0.0 > >>> Application Timestamp:4f84a6c8 > >>> Fault Module Name:ADVAPI32.dll > >>> Fault Module Version:6.1.7600.16385 > >>> Fault Module Timestamp:4a5bd97e > >>> Exception Code:c0000005 > >>> Exception Offset:00019347 > >>> OS Version:6.1.7600.2.0.0.274.10 > >>> Locale ID:1033 > >>> Additional Information 1:0a9e > >>> Additional Information 2:**0a9e372d3b4ad19135b953a78882e7**89 > >>> Additional Information 3:0a9e > >>> Additional Information 4:**0a9e372d3b4ad19135b953a78882e7**89 > >>> > >>> Read our privacy statement online: > >>> http://go.microsoft.com/**fwlink/?linkid=104288&clcid=**0x0409< > http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409> > >>> > >>> If the online privacy statement is not available, please read our > >>> privacy statement offline: > >>> C:\Windows\system32\en-US\**erofflps.txt > >>> > >>> > >>> > >>> > >>> ______________________________**_________________ > >>> python-win32 mailing list > >>> python-win32 at python.org > >>> http://mail.python.org/**mailman/listinfo/python-win32< > 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 > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri May 4 20:33:05 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 4 May 2012 11:33:05 -0700 Subject: [python-win32] Accessing methods from python-based COM DLL generated using py2exe In-Reply-To: References: <5E6F13034AEF334F9D175E1F28BCDAFF060E427D@001FSN2MPN1-015.001f.mgd2.msft.net>, <4FA2BE34.80000@probo.com> Message-ID: <4FA420E1.6020206@probo.com> Alexis Ellis wrote: > Thank you for your help. I was obviously headed down the wrong path. > As per your suggestion, I am now using comtypes to create a com server. You mean Pythoncom, right? >> python myserver.py /regserver > I get the following error: > > Traceback (most recent call last): > File "myserver.py", line 23, in > import win32com.server.register > File "c:\python26\arcgis10.0\lib\site-packages\win32com\server\register.py", l > ine 13, in > import winerror > File "c:\python26\arcgis10.0\winerror.py", line 3, in > from nterror import * > File "c:\python26\arcgis10.0\nterror.py", line 4, in > import windll > File "c:\python26\arcgis10.0\windll.py", line 20, in > import calldll > ImportError: No module named calldll I don't understand your paths at all. What is "arcgis10.0" doing in there? How did you install Python? Your standard library is living in a subdirectory of that, instead of in \python2.6, where it would ordinarily live. win32com\server\register.py is trying to include "winerror.py", which is part of the normal PyWin32 distribution, in win32\lib. However, for some reason, it is finding winerror.py from \python26\arcgis.10.0 instead. That can't be healthy. register.py is expecting the one in win32\lib. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From alan.jump at gmail.com Sun May 6 03:24:54 2012 From: alan.jump at gmail.com (Alan Jump) Date: Sat, 05 May 2012 18:24:54 -0700 Subject: [python-win32] A little help for a n00b, please Message-ID: <4FA5D2E6.5020800@gmail.com> Trying to massage an older package (not written by me) into functioning order. The issue I'm having is getting printing functionality to work. The code snippet in question: if platform.system() == 'Windows': try: import win32api except: print('* FAILED TO LOAD WINDOWS EXTENSION') return try: win32api.ShellExecute (0, "print", filename, None, ".", 0) except: print('* FAILED TO SEND PRINT TO WINDOWS PRINTER') return The output file is generated in a separate code section and the filename being passed has been verified, but I invariably get the message in the second exception. That tells me the win32api is being properly imported, but for some reason, it's throwing an exception when trying to write to the print device. I commented out the "try - except" statements, and got an error message that the device could not be opened. I'm wondering if there's a UAC or permissions issue I'm running up against. Specifics: Windows Vista Home Basic, fully patched. Python 3.2, PyWindows build 217. 73 de N5ILN/6 Alan From vernondcole at gmail.com Sun May 6 05:44:22 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Sat, 5 May 2012 21:44:22 -0600 Subject: [python-win32] A little help for a n00b, please In-Reply-To: <4FA5D2E6.5020800@gmail.com> References: <4FA5D2E6.5020800@gmail.com> Message-ID: First, make sure that you can type "print somefile.txt" on a console command line and get it to work. Often the old DOS style print command - which is what you are trying here - will not work on new Windows printers. You may very likely have to use a much more complex method involving the Windows print spooler. On May 5, 2012 7:25 PM, "Alan Jump" wrote: > Trying to massage an older package (not written by me) into functioning > order. The issue I'm having is getting printing functionality to work. > The code snippet in question: > > if platform.system() == 'Windows': > try: > import win32api > except: > print('* FAILED TO LOAD WINDOWS EXTENSION') > return > try: > win32api.ShellExecute (0, "print", filename, None, ".", 0) > except: > print('* FAILED TO SEND PRINT TO WINDOWS PRINTER') > return > > The output file is generated in a separate code section and the filename > being passed has been verified, but I invariably get the message in the > second exception. That tells me the win32api is being properly imported, > but for some reason, it's throwing an exception when trying to write to > the print device. I commented out the "try - except" statements, and got > an error message that the device could not be opened. I'm wondering if > there's a UAC or permissions issue I'm running up against. > > Specifics: Windows Vista Home Basic, fully patched. Python 3.2, > PyWindows build 217. > > 73 de N5ILN/6 > Alan > _______________________________________________ > 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 mail at timgolden.me.uk Sun May 6 10:50:50 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 06 May 2012 09:50:50 +0100 Subject: [python-win32] A little help for a n00b, please In-Reply-To: <4FA5D2E6.5020800@gmail.com> References: <4FA5D2E6.5020800@gmail.com> Message-ID: <4FA63B6A.5050408@timgolden.me.uk> On 06/05/2012 02:24, Alan Jump wrote: > Trying to massage an older package (not written by me) into functioning > order. The issue I'm having is getting printing functionality to work. > The code snippet in question: > > if platform.system() == 'Windows': > try: > import win32api > except: > print('* FAILED TO LOAD WINDOWS EXTENSION') > return > try: > win32api.ShellExecute (0, "print", filename, None, ".", 0) > except: > print('* FAILED TO SEND PRINT TO WINDOWS PRINTER') > return > > The output file is generated in a separate code section and the filename > being passed has been verified, but I invariably get the message in the > second exception. That tells me the win32api is being properly imported, > but for some reason, it's throwing an exception when trying to write to > the print device. Some general advice for a start: you almost *never* want to use a general except: clause (ie without a specific exception class): it catches *everything* - including Ctrl-C. So, in the try-except around "import win32api" you just want to catch ImportErrors -- at least, I assume so. However, you've circumvented that particular issue by removing the except clause from your ShellExecute command. Contrary to Vernon's suggestion, that won't actually be using the DOS "print" command but rather passing the "print" verb along to the application which is registered against the filename in question via the Shell verb handling mechanism. It would be interesting to see the exact error message you get but permissions or UAC is definitely a possibility. Also, and this is where it gets messier, the "print" verb will, in most cases, go to the *default* printer on the machine you're on -- and with the default settings. It's possible that this isn't the printer you think it is. Some applications keep their own track of which printer you last used, so you might fail to realise which one is actually the default. If that is the case you might want to look at this: http://timgolden.me.uk/python/win32_how_do_i/print.html#shellexecute for a possible way to specify a printer. TJG From alan.jump at gmail.com Sun May 6 19:07:14 2012 From: alan.jump at gmail.com (Alan Jump) Date: Sun, 06 May 2012 10:07:14 -0700 Subject: [python-win32] A little help for a n00b, please In-Reply-To: <4FA6A6D1.2070302@gmail.com> References: <4FA6A6D1.2070302@gmail.com> Message-ID: <4FA6AFC2.5080003@gmail.com> (Originally sent just to Tim...serves me right for trying to think before I've had my second cuppa.) Much obliged to both you and Vernon. I'm going to be adding quite a few code snippets to these emails, just to let the various search engines work their magic in case anyone besides me is running into the same problem. I tried a couple of the extended commands on the web page, and still got the same exception message. The altered section is as follows: if platform.system() == 'Windows': try: import win32api import win32print # new import to allow for direction to default printer except: print('* FAILED TO LOAD WINDOWS EXTENSION') return try: win32api.ShellExecute (0, "printto", filename, '"%s"' % win32print.GetDefaultPrinter (), ".", 0) # altered ShellExecute() parameter except: print('* FAILED TO SEND PRINT TO WINDOWS PRINTER') return I ran a code evaluation in my IDE (Wing IDE, for those keeping score). The error message: pywintypes.error: (31, 'ShellExecute', 'A device attached to the system is not functioning.') I double-checked that the interpreter was seeing the printer: >>> win32print.GetDefaultPrinter() 'Canon iP4800 series' Taking Vernon's hint, I was also not able to print a file using the command-line "print" statement. So although the win32print.GetDefaultPrinter() function is seeing the default printer correctly, and the printer operates correctly in any actual WinXX program, it's not being recognized outside WinXX. The problem with using the "print" command, though, is that it wants to see either the default PRN device, or a specific output port (USB7:, LPT0:, etc.) The next troubleshooting step is to see if there are driver updates, since it's not printing from the command line. Thanks again. 73 de N5ILN/6 Alan On 5/6/2012 1:50 AM, Tim Golden wrote: > On 06/05/2012 02:24, Alan Jump wrote: >> Trying to massage an older package (not written by me) into functioning >> order. The issue I'm having is getting printing functionality to work. >> The code snippet in question: >> >> if platform.system() == 'Windows': >> try: >> import win32api >> except: >> print('* FAILED TO LOAD WINDOWS EXTENSION') >> return >> try: >> win32api.ShellExecute (0, "print", filename, None, >> ".", 0) >> except: >> print('* FAILED TO SEND PRINT TO WINDOWS PRINTER') >> return >> >> The output file is generated in a separate code section and the filename >> being passed has been verified, but I invariably get the message in the >> second exception. That tells me the win32api is being properly imported, >> but for some reason, it's throwing an exception when trying to write to >> the print device. > > Some general advice for a start: you almost *never* want to > use a general except: clause (ie without a specific exception > class): it catches *everything* - including Ctrl-C. So, in > the try-except around "import win32api" you just want to > catch ImportErrors -- at least, I assume so. > > However, you've circumvented that particular issue by removing > the except clause from your ShellExecute command. Contrary to > Vernon's suggestion, that won't actually be using the DOS > "print" command but rather passing the "print" verb along to > the application which is registered against the filename in > question via the Shell verb handling mechanism. > > It would be interesting to see the exact error message you > get but permissions or UAC is definitely a possibility. Also, > and this is where it gets messier, the "print" verb will, in > most cases, go to the *default* printer on the machine you're > on -- and with the default settings. It's possible that this > isn't the printer you think it is. Some applications keep their > own track of which printer you last used, so you might fail to > realise which one is actually the default. > > If that is the case you might want to look at this: > > http://timgolden.me.uk/python/win32_how_do_i/print.html#shellexecute > > for a possible way to specify a printer. > > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Sun May 6 19:20:41 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 06 May 2012 18:20:41 +0100 Subject: [python-win32] A little help for a n00b, please In-Reply-To: <4FA6AFC2.5080003@gmail.com> References: <4FA6A6D1.2070302@gmail.com> <4FA6AFC2.5080003@gmail.com> Message-ID: <4FA6B2E9.1010607@timgolden.me.uk> On 06/05/2012 18:07, Alan Jump wrote: > Much obliged to both you and Vernon. I'm going to be adding quite a few > code snippets to these emails, just to let the various search engines > work their magic in case anyone besides me is running into the same problem. > > I tried a couple of the extended commands on the web page, and still got > the same exception message. At the risk of asking you to do the obvious, what happens if you do this: import win32api open ("test.txt", "w").write ("TESTING") win32api.ShellExecute (0, "print", "test.txt", None, ".", 0) In other words, is there a problem sending *anything* to print via a Shell Execute? Or is there something specific to your app? TJG From alan.jump at gmail.com Sun May 6 19:37:36 2012 From: alan.jump at gmail.com (Alan Jump) Date: Sun, 06 May 2012 10:37:36 -0700 Subject: [python-win32] A little help for a n00b, please In-Reply-To: <4FA6B2E9.1010607@timgolden.me.uk> References: <4FA6A6D1.2070302@gmail.com> <4FA6AFC2.5080003@gmail.com> <4FA6B2E9.1010607@timgolden.me.uk> Message-ID: <4FA6B6E0.5070105@gmail.com> I entered it in the shell, being too lazy to write a separate script file. The response is the same: Traceback (most recent call last): File "", line 1, in pywintypes.error: (31, 'ShellExecute', 'A device attached to the system is not functioning.') So it's apparently an issue with my system, rather than the script. I've tried changing print processors and updating drivers, but to no avail. So I'm thinking this is not a Python problem, but a Windows problem, which means I dig elsewhere for the gem that fixes the problem. Thanks again. 73 de N5ILN/6 Alan On 5/6/2012 10:20 AM, Tim Golden wrote: > On 06/05/2012 18:07, Alan Jump wrote: >> Much obliged to both you and Vernon. I'm going to be adding quite a few >> code snippets to these emails, just to let the various search engines >> work their magic in case anyone besides me is running into the same >> problem. >> >> I tried a couple of the extended commands on the web page, and still got >> the same exception message. > > At the risk of asking you to do the obvious, what happens > if you do this: > > > import win32api > > open ("test.txt", "w").write ("TESTING") > win32api.ShellExecute (0, "print", "test.txt", None, ".", 0) > > > > In other words, is there a problem sending *anything* > to print via a Shell Execute? Or is there something > specific to your app? > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Sun May 6 20:40:30 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 06 May 2012 19:40:30 +0100 Subject: [python-win32] A little help for a n00b, please In-Reply-To: <4FA6B6E0.5070105@gmail.com> References: <4FA6A6D1.2070302@gmail.com> <4FA6AFC2.5080003@gmail.com> <4FA6B2E9.1010607@timgolden.me.uk> <4FA6B6E0.5070105@gmail.com> Message-ID: <4FA6C59E.5000309@timgolden.me.uk> On 06/05/2012 18:37, Alan Jump wrote: > I entered it in the shell, being too lazy to write a separate script > file. The response is the same: > > > Traceback (most recent call last): > File "", line 1, in > pywintypes.error: (31, 'ShellExecute', 'A device attached to the system > is not functioning.') > > > So it's apparently an issue with my system, rather than the script. I've > tried changing print processors and updating drivers, but to no avail. > So I'm thinking this is not a Python problem, but a Windows problem, > which means I dig elsewhere for the gem that fixes the problem. Most of the pywin32 functionality exposes the underlying win32 api more or less raw. (Doing only what's necessary to map Python objects to and from their Windows counterparts). So it's fairly unusual for Python to introduce any complexity into this kind of situation. BTW, the custom on this list is to bottom-post or inter-post rather than top-posting. Just so you know... TJG From iinjdpa at gmail.com Tue May 8 00:26:44 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Tue, 8 May 2012 00:26:44 +0200 Subject: [python-win32] speed up win32com.client Message-ID: Hello, I am writing code to program AutoCAD access from Python using pywin32. When I need to work with a high number of AutoCAD objects, it is faster to use vba than python. Are there some way to speed up python code in order to work faster with AutoCAD elements? For example in the next code when I work with 512 AutoCAD blocks: import win32com.client import time t1=time.clock() acad= win32com.client.Dispatch("AutoCAD.Application") doc = acad.ActiveDocument seleccion=doc.SelectionSets.Add('selection6') seleccion.SelectOnScreen() t2=time.clock() M=[] for objeto in seleccion: if objeto.ObjectName=='AcDbBlockReference': M.append(objeto.InsertionPoint) t3=time.clock() print 'M_dimension=',len(M) R=[] for m in M: for x in M: R.append(max(m)+max(x)) print 'R_dimension=',len(R) t4=time.clock() t_block1=t2-t1 t_block2=t3-t2 t_block3=t4-t3 print 't_block1=',t_block1 print 't_block2=',t_block2 print 't_block3=',t_block3 The output for the code is the following: M_dimension= 512 R_dimension= 262144 t_block1= 4.25343304805 t_block2= 3.88635510938 t_block3= 0.487477319045 Then it is faster to work with R than M, even though R is bigger. Some suggestions for speed up pywin32 code in this example? Best Regards, Daniel Pose. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue May 8 18:45:13 2012 From: timr at probo.com (Tim Roberts) Date: Tue, 8 May 2012 09:45:13 -0700 Subject: [python-win32] speed up win32com.client In-Reply-To: References: Message-ID: <4FA94D99.2000404@probo.com> DANIEL POSE wrote: > Hello, > > I am writing code to program AutoCAD access from Python using pywin32. > When I need to work with a high number of AutoCAD objects, it is > faster to use vba than python. > Are there some way to speed up python code in order to work faster > with AutoCAD elements? > For example in the next code when I work with 512 AutoCAD blocks: > ... > > The output for the code is the following: > > M_dimension= 512 > R_dimension= 262144 > t_block1= 4.25343304805 > t_block2= 3.88635510938 > t_block3= 0.487477319045 > > > Then it is faster to work with R than M, even though R is bigger. > I hope that's not a surprise to you. The first loop (block2) involves two calls into the AutoCAD COM object in each iteration. The second loop (block3) is simply manipulating lists of integers, entirely within Python. > Some suggestions for speed up pywin32 code in this example? > There isn't really anything here to speed up. You're just "glue". The work is being done in AutoCAD. It is almost impossible for me to believe that Visual Basic does this same loop any faster. However, you can certainly try switching to early binding by using: acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tom at pentest.7safe.com Wed May 9 16:33:57 2012 From: tom at pentest.7safe.com (Tom) Date: Wed, 9 May 2012 15:33:57 +0100 Subject: [python-win32] speed up win32com.client In-Reply-To: <4FA94D99.2000404@probo.com> References: <4FA94D99.2000404@probo.com> Message-ID: Sorry to interject here but I have a question along the same vein: If I have a script (in this case that interacts with Word through win32com.client) with statements like this: doc.ActiveWindow.Selection.BoldRun() doc.ActiveWindow.Selection.TypeText(_type) doc.ActiveWindow.Selection.BoldRun() Does each line require 3 COM calls, one for ActiveWindow, one for Selection and one for the method being called, or is the Selection object cached somewhere? The question really is the code below more efficient than the code above in terms of COM calls, or is the difference minimal? selec = doc.ActiveWindow.Selection selec.BoldRun() selec.TypeText(_type) selec.BoldRun() Its something I have always wondered. Thanks! On Tue, May 8, 2012 at 5:45 PM, Tim Roberts wrote: > DANIEL POSE wrote: > > Hello, > > > > I am writing code to program AutoCAD access from Python using pywin32. > > When I need to work with a high number of AutoCAD objects, it is > > faster to use vba than python. > > Are there some way to speed up python code in order to work faster > > with AutoCAD elements? > > For example in the next code when I work with 512 AutoCAD blocks: > > ... > > > > The output for the code is the following: > > > > M_dimension= 512 > > R_dimension= 262144 > > t_block1= 4.25343304805 > > t_block2= 3.88635510938 > > t_block3= 0.487477319045 > > > > > > Then it is faster to work with R than M, even though R is bigger. > > > > I hope that's not a surprise to you. The first loop (block2) involves > two calls into the AutoCAD COM object in each iteration. The second > loop (block3) is simply manipulating lists of integers, entirely within > Python. > > > Some suggestions for speed up pywin32 code in this example? > > > > There isn't really anything here to speed up. You're just "glue". The > work is being done in AutoCAD. It is almost impossible for me to > believe that Visual Basic does this same loop any faster. > > However, you can certainly try switching to early binding by using: > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iinjdpa at gmail.com Wed May 9 22:38:17 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Wed, 9 May 2012 22:38:17 +0200 Subject: [python-win32] speed up win32com.client In-Reply-To: <4FA94D99.2000404@probo.com> References: <4FA94D99.2000404@probo.com> Message-ID: I have read about Early Binding but I hadn't tested the line that you reference: acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") For my surprise, if I replace line: acad= win32com.client.Dispatch("AutoCAD.Application") for the line: acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") I have an error about a missing attribute in the line: M.append(objeto.InsertionPoint) The problem here is that if now I go back to use the line: acad= win32com.client.Dispatch("AutoCAD.Application") Now pywin32 brokes and I have always the same error in line: M.append(objeto.InsertionPoint) I need to reinstall pywin32 in order to repair the problem. 2012/5/8 Tim Roberts > DANIEL POSE wrote: > > Hello, > > > > I am writing code to program AutoCAD access from Python using pywin32. > > When I need to work with a high number of AutoCAD objects, it is > > faster to use vba than python. > > Are there some way to speed up python code in order to work faster > > with AutoCAD elements? > > For example in the next code when I work with 512 AutoCAD blocks: > > ... > > > > The output for the code is the following: > > > > M_dimension= 512 > > R_dimension= 262144 > > t_block1= 4.25343304805 > > t_block2= 3.88635510938 > > t_block3= 0.487477319045 > > > > > > Then it is faster to work with R than M, even though R is bigger. > > > > I hope that's not a surprise to you. The first loop (block2) involves > two calls into the AutoCAD COM object in each iteration. The second > loop (block3) is simply manipulating lists of integers, entirely within > Python. > > > Some suggestions for speed up pywin32 code in this example? > > > > There isn't really anything here to speed up. You're just "glue". The > work is being done in AutoCAD. It is almost impossible for me to > believe that Visual Basic does this same loop any faster. > > However, you can certainly try switching to early binding by using: > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Rohit.Nirantar at wellsfargo.com Fri May 11 06:02:40 2012 From: Rohit.Nirantar at wellsfargo.com (Rohit.Nirantar at wellsfargo.com) Date: Fri, 11 May 2012 00:02:40 -0400 Subject: [python-win32] Help needed on Dispatch Message-ID: Hi All, I am getting error while trying to execute code: from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") Dispatch C:\Python27\lib\site-packages\win32com\client\__init__.py 95 _GetGoodDispatchAndUserName C:\Python27\lib\site-packages\win32com\client\dynamic.py 108 _GetGoodDispatch C:\Python27\lib\site-packages\win32com\client\dynamic.py 85 com_error: (-2147221005, 'Invalid class string', None, None) Can anyone please help me. Thanks ________________________________ This email is subject to a disclaimer, please click on the following link or cut and paste the link into the address bar of your browser. https://www.wellsfargo.com/com/disclaimer/ged2 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri May 11 19:10:11 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 11 May 2012 10:10:11 -0700 Subject: [python-win32] Help needed on Dispatch In-Reply-To: References: Message-ID: <4FAD47F3.7050909@probo.com> Rohit.Nirantar at wellsfargo.com wrote: > Hi All, > > I am getting error while trying to execute code: > > from win32com.client import Dispatch > xlApp = Dispatch("Excel.Application") > > Dispatch > C:\Python27\lib\site-packages\win32com\client\__init__.py > 95 > _GetGoodDispatchAndUserName > C:\Python27\lib\site-packages\win32com\client\dynamic.py > 108 > _GetGoodDispatch > C:\Python27\lib\site-packages\win32com\client\dynamic.py > 85 > com_error: (-2147221005, 'Invalid class string', None, None) The most likely explanation is that you do not have Excel installed on your computer. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Sat May 12 05:32:53 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 12 May 2012 13:32:53 +1000 Subject: [python-win32] speed up win32com.client In-Reply-To: References: <4FA94D99.2000404@probo.com> Message-ID: <4FADD9E5.1060403@gmail.com> On 10/05/2012 12:33 AM, Tom wrote: > Sorry to interject here but I have a question along the same vein: > If I have a script (in this case that interacts with Word through > win32com.client) with statements like this: > doc.ActiveWindow.Selection.BoldRun() > doc.ActiveWindow.Selection.TypeText(_type) > doc.ActiveWindow.Selection.BoldRun() > > Does each line require 3 COM calls, one for ActiveWindow, one for > Selection and one for the method being called, or is the Selection > object cached somewhere? It requires 3 COM calls - there is no caching (and your code above is a good example of why - the "ActiveWindow" could easily change between the value being cached and it being reused). > The question really is the code below more efficient than the code above > in terms of COM calls, or is the difference minimal? > selec = doc.ActiveWindow.Selection > selec.BoldRun() > selec.TypeText(_type) > selec.BoldRun() The above would be more efficient. Cheers, Mark > > Its something I have always wondered. Thanks! > > On Tue, May 8, 2012 at 5:45 PM, Tim Roberts > wrote: > > DANIEL POSE wrote: > > Hello, > > > > I am writing code to program AutoCAD access from Python using > pywin32. > > When I need to work with a high number of AutoCAD objects, it is > > faster to use vba than python. > > Are there some way to speed up python code in order to work faster > > with AutoCAD elements? > > For example in the next code when I work with 512 AutoCAD blocks: > > ... > > > > The output for the code is the following: > > > > M_dimension= 512 > > R_dimension= 262144 > > t_block1= 4.25343304805 > > t_block2= 3.88635510938 > > t_block3= 0.487477319045 > > > > > > Then it is faster to work with R than M, even though R is bigger. > > > > I hope that's not a surprise to you. The first loop (block2) involves > two calls into the AutoCAD COM object in each iteration. The second > loop (block3) is simply manipulating lists of integers, entirely within > Python. > > > Some suggestions for speed up pywin32 code in this example? > > > > There isn't really anything here to speed up. You're just "glue". The > work is being done in AutoCAD. It is almost impossible for me to > believe that Visual Basic does this same loop any faster. > > However, you can certainly try switching to early binding by using: > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > -- > 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 > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From skippy.hammond at gmail.com Sat May 12 05:36:14 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 12 May 2012 13:36:14 +1000 Subject: [python-win32] speed up win32com.client In-Reply-To: References: <4FA94D99.2000404@probo.com> Message-ID: <4FADDAAE.5070500@gmail.com> On 10/05/2012 6:38 AM, DANIEL POSE wrote: > I have read about Early Binding but I hadn't tested the line that you > reference: > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > For my surprise, if I replace line: > > acad= win32com.client.Dispatch("AutoCAD.Application") > > for the line: > > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > I have an error about a missing attribute in the line: > > M.append(objeto.InsertionPoint) Once you use early-binding, the object becomes case sensitive where it usually wasn't before. So I suspect you wanted something like "insertionPoint" or some other difference in case. > The problem here is that if now I go back to use the line: > > acad= win32com.client.Dispatch("AutoCAD.Application") > > Now pywin32 brokes and I have always the same error in line: > M.append(objeto.InsertionPoint) > > I need to reinstall pywin32 in order to repair the problem. Yeah, this is unfortunate - once you've generated the early binding support, win32com.client.Dispatch will generally be able to use it. A work around without reinstalling would have been to delete the win32com\client\gen_py directory. HTH, Mark > > > > 2012/5/8 Tim Roberts > > > DANIEL POSE wrote: > > Hello, > > > > I am writing code to program AutoCAD access from Python using > pywin32. > > When I need to work with a high number of AutoCAD objects, it is > > faster to use vba than python. > > Are there some way to speed up python code in order to work faster > > with AutoCAD elements? > > For example in the next code when I work with 512 AutoCAD blocks: > > ... > > > > The output for the code is the following: > > > > M_dimension= 512 > > R_dimension= 262144 > > t_block1= 4.25343304805 > > t_block2= 3.88635510938 > > t_block3= 0.487477319045 > > > > > > Then it is faster to work with R than M, even though R is bigger. > > > > I hope that's not a surprise to you. The first loop (block2) involves > two calls into the AutoCAD COM object in each iteration. The second > loop (block3) is simply manipulating lists of integers, entirely within > Python. > > > Some suggestions for speed up pywin32 code in this example? > > > > There isn't really anything here to speed up. You're just "glue". The > work is being done in AutoCAD. It is almost impossible for me to > believe that Visual Basic does this same loop any faster. > > However, you can certainly try switching to early binding by using: > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > -- > 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 > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From skippy.hammond at gmail.com Sat May 12 05:37:27 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 12 May 2012 13:37:27 +1000 Subject: [python-win32] Help needed on Dispatch In-Reply-To: References: Message-ID: <4FADDAF7.8020606@gmail.com> Or as a follow-up to Tim's response, the other likely scenario is that you have a 32bit Excel but a 64bit Python. So if that sounds likely, just remove the 64bit Python and use a 32bit version. Cheers, Mark On 11/05/2012 2:02 PM, Rohit.Nirantar at wellsfargo.com wrote: > Hi All, > I am getting error while trying to execute code: > from win32com.client import Dispatch > xlApp = Dispatch("Excel.Application") > Dispatch > C:\Python27\lib\site-packages\win32com\client\__init__.py 95 > _GetGoodDispatchAndUserName > C:\Python27\lib\site-packages\win32com\client\dynamic.py 108 > _GetGoodDispatch > C:\Python27\lib\site-packages\win32com\client\dynamic.py 85 > com_error: (-2147221005, 'Invalid class string', None, None) > Can anyone please help me. > Thanks > > _ ________________________________ _ > This email is subject to a disclaimer, please click on the following > link or cut and paste the link into the address bar of your browser. > > https://www.wellsfargo.com/com/disclaimer/ged2 > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From iinjdpa at gmail.com Sat May 12 21:00:20 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Sat, 12 May 2012 21:00:20 +0200 Subject: [python-win32] speed up win32com.client In-Reply-To: <4FADDAAE.5070500@gmail.com> References: <4FA94D99.2000404@probo.com> <4FADDAAE.5070500@gmail.com> Message-ID: I had tried to change attribute name in several ways (InsertionPoint, insertionPoint, insertionpoint,...) but I obtained the same error: Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", line 128, in runfile execfile(filename, glbs) File "C:\Documents and Settings\Usuario\Mis documentos\Dropbox\PYTHON\PruebaAutoCAD.py", line 29, in M.append(objeto.insertionpoint) File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 465, in __getattr__ raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) AttributeError: '' object has no attribute 'insertionpoint' If I delete only the win32com\client\gen_py folder It doesn't work. I need delete for example win32com and win32 folders and restore older ones. 2012/5/12 Mark Hammond > On 10/05/2012 6:38 AM, DANIEL POSE wrote: > >> I have read about Early Binding but I hadn't tested the line that you >> reference: >> acad= win32com.client.gencache.**EnsureDispatch("AutoCAD.**Application") >> >> For my surprise, if I replace line: >> >> acad= win32com.client.Dispatch("**AutoCAD.Application") >> >> for the line: >> >> acad= win32com.client.gencache.**EnsureDispatch("AutoCAD.**Application") >> >> I have an error about a missing attribute in the line: >> >> M.append(objeto.**InsertionPoint) >> > > Once you use early-binding, the object becomes case sensitive where it > usually wasn't before. So I suspect you wanted something like > "insertionPoint" or some other difference in case. > > > The problem here is that if now I go back to use the line: >> >> acad= win32com.client.Dispatch("**AutoCAD.Application") >> >> Now pywin32 brokes and I have always the same error in line: >> M.append(objeto.**InsertionPoint) >> >> I need to reinstall pywin32 in order to repair the problem. >> > > Yeah, this is unfortunate - once you've generated the early binding > support, win32com.client.Dispatch will generally be able to use it. A work > around without reinstalling would have been to delete the > win32com\client\gen_py directory. > > HTH, > > Mark > > >> >> >> 2012/5/8 Tim Roberts > >> >> >> DANIEL POSE wrote: >> > Hello, >> > >> > I am writing code to program AutoCAD access from Python using >> pywin32. >> > When I need to work with a high number of AutoCAD objects, it is >> > faster to use vba than python. >> > Are there some way to speed up python code in order to work faster >> > with AutoCAD elements? >> > For example in the next code when I work with 512 AutoCAD blocks: >> > ... >> > >> > The output for the code is the following: >> > >> > M_dimension= 512 >> > R_dimension= 262144 >> > t_block1= 4.25343304805 >> > t_block2= 3.88635510938 >> > t_block3= 0.487477319045 >> > >> > >> > Then it is faster to work with R than M, even though R is bigger. >> > >> >> I hope that's not a surprise to you. The first loop (block2) involves >> two calls into the AutoCAD COM object in each iteration. The second >> loop (block3) is simply manipulating lists of integers, entirely within >> Python. >> >> > Some suggestions for speed up pywin32 code in this example? >> > >> >> There isn't really anything here to speed up. You're just "glue". The >> work is being done in AutoCAD. It is almost impossible for me to >> believe that Visual Basic does this same loop any faster. >> >> However, you can certainly try switching to early binding by using: >> acad= win32com.client.gencache.**EnsureDispatch("AutoCAD.** >> Application") >> >> -- >> 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 >> >> >> >> >> >> ______________________________**_________________ >> 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 dan.glassman at gmail.com Sat May 12 22:37:28 2012 From: dan.glassman at gmail.com (Dan Glassman) Date: Sat, 12 May 2012 15:37:28 -0500 Subject: [python-win32] speed up win32com.client In-Reply-To: References: Message-ID: VBA is faster because it's running in-process inside AutoCAD (everything is loaded into acad.exe). Python runs out-of-process (AutoCAD objects need to be passed back and forth between acad.exe and python.exe). You can use AutoCAD's ObjectARX API to embed python inside AutoCAD and make python in-process; you'll get a significant speedup. You'll need to know C++ in order to do that. Let me know if you'd like further details. 64-bit AutoCAD runs VBA out-of-process because there is no 64-bit VBA; you'd see the same slowness there that you're seeing with python. -drg On Mon, May 7, 2012 at 5:26 PM, DANIEL POSE wrote: > Hello, > > I am writing code to program AutoCAD access from Python using pywin32. > When I need to work with a high number of AutoCAD objects, it is faster to > use vba than python. > Are there some way to speed up python code in order to work faster with > AutoCAD elements? > For example in the next code when I work with 512 AutoCAD blocks: > > import win32com.client > > import time > > t1=time.clock() > > acad= win32com.client.Dispatch("AutoCAD.Application") > > doc = acad.ActiveDocument > > seleccion=doc.SelectionSets.Add('selection6') > > seleccion.SelectOnScreen() > > t2=time.clock() > > M=[] > > for objeto in seleccion: > > if objeto.ObjectName=='AcDbBlockReference': > > M.append(objeto.InsertionPoint) > > t3=time.clock() > > print 'M_dimension=',len(M) > > R=[] > > for m in M: > > for x in M: > > R.append(max(m)+max(x)) > > print 'R_dimension=',len(R) > > t4=time.clock() > > t_block1=t2-t1 > > t_block2=t3-t2 > > t_block3=t4-t3 > > print 't_block1=',t_block1 > > print 't_block2=',t_block2 > > print 't_block3=',t_block3 > > > The output for the code is the following: > > M_dimension= 512 > R_dimension= 262144 > t_block1= 4.25343304805 > t_block2= 3.88635510938 > t_block3= 0.487477319045 > > > Then it is faster to work with R than M, even though R is bigger. > > Some suggestions for speed up pywin32 code in this example? > > > Best Regards, > > Daniel Pose. > > > > > > > _______________________________________________ > 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 ed.shallow at gmail.com Sat May 12 14:31:38 2012 From: ed.shallow at gmail.com (EdShallow) Date: Sat, 12 May 2012 08:31:38 -0400 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 Message-ID: Hi Folks, I have an ActiveX COM dll generated by VisualBasic 6 in WinXP. I can call it and use it successfully with Python 2.3 and pywin32-208 without problems. As soon as I upgrade either pywin32- or Python to anything itself to anything newer, my dll throws an exception immediately upon entry. Can anyone point me in a general direction with respect to addressing this incompatibility? Thanks, Ed -- Ed's Contact Information: Mobile Phone: 613-852-6410 Gmail: ed.shallow at gmail.com VOIP Address: 107529 at sip.ca1.voip.ms VOIP DID#: 613-458-5004 Skype ID: edward.shallow Home Phone: 613-482-2090 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Sun May 13 04:35:17 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 13 May 2012 12:35:17 +1000 Subject: [python-win32] speed up win32com.client In-Reply-To: References: <4FA94D99.2000404@probo.com> <4FADDAAE.5070500@gmail.com> Message-ID: <4FAF1DE5.7080903@skippinet.com.au> On 13/05/2012 5:00 AM, DANIEL POSE wrote: > I had tried to change attribute name in several ways (InsertionPoint, > insertionPoint, insertionpoint,...) but I obtained the same error: > > Traceback (most recent call last): > File "", line 1, in > File > "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", > line 128, in runfile > execfile(filename, glbs) > File "C:\Documents and Settings\Usuario\Mis > documentos\Dropbox\PYTHON\PruebaAutoCAD.py", line 29, in > M.append(objeto.insertionpoint) > File "C:\Python27\lib\site-packages\win32com\client\__init__.py", > line 465, in __getattr__ > raise AttributeError("'%s' object has no attribute '%s'" % > (repr(self), attr)) > AttributeError: ' instance at 0x88940672>' object has no attribute 'insertionpoint' In the gen_py directory you should find a generated file supporting the AutoCAD object - it will have a GUID in its name so it might not be obvious which one applies, but inside that you should find the 'IAcadEntity' object. That should have a _prop_map_get attribute which lists the attributes available on the object - I'd expect to find insertionPoint listed there. It may turn out it is actually on a different object, in which case the win32com.client.CastTo() function might be useful to get the appropriate interface. > If I delete only the win32com\client\gen_py folder It doesn't work. I > need delete for example win32com and win32 folders and restore older ones. Hrm - I certainly can't explain that! Or maybe I can - check your %TEMP% folder and see if there is a gen_py directory there? Mark From iinjdpa at gmail.com Sun May 13 13:42:24 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Sun, 13 May 2012 13:42:24 +0200 Subject: [python-win32] speed up win32com.client In-Reply-To: References: Message-ID: Thank you Dan, by now it is clear for me. Unfortunately I haven't C++ knowledge but don't worry, for me it is enought to know that the problem is not in python or in my code. Now I am occasionaly programmer in Python or VBA, then it would be too complicated for me to learn C++, but perhaps I will consider this question in the future. 2012/5/12 Dan Glassman > VBA is faster because it's running in-process inside AutoCAD (everything > is loaded into acad.exe). Python runs out-of-process (AutoCAD objects need > to be passed back and forth between acad.exe and python.exe). > > You can use AutoCAD's ObjectARX API to embed python inside AutoCAD and > make python in-process; you'll get a significant speedup. You'll need to > know C++ in order to do that. Let me know if you'd like further details. > > 64-bit AutoCAD runs VBA out-of-process because there is no 64-bit VBA; > you'd see the same slowness there that you're seeing with python. > > -drg > > > > On Mon, May 7, 2012 at 5:26 PM, DANIEL POSE wrote: > >> Hello, >> >> I am writing code to program AutoCAD access from Python using pywin32. >> When I need to work with a high number of AutoCAD objects, it is faster to >> use vba than python. >> Are there some way to speed up python code in order to work faster with >> AutoCAD elements? >> For example in the next code when I work with 512 AutoCAD blocks: >> >> import win32com.client >> >> import time >> >> t1=time.clock() >> >> acad= win32com.client.Dispatch("AutoCAD.Application") >> >> doc = acad.ActiveDocument >> >> seleccion=doc.SelectionSets.Add('selection6') >> >> seleccion.SelectOnScreen() >> >> t2=time.clock() >> >> M=[] >> >> for objeto in seleccion: >> >> if objeto.ObjectName=='AcDbBlockReference': >> >> M.append(objeto.InsertionPoint) >> >> t3=time.clock() >> >> print 'M_dimension=',len(M) >> >> R=[] >> >> for m in M: >> >> for x in M: >> >> R.append(max(m)+max(x)) >> >> print 'R_dimension=',len(R) >> >> t4=time.clock() >> >> t_block1=t2-t1 >> >> t_block2=t3-t2 >> >> t_block3=t4-t3 >> >> print 't_block1=',t_block1 >> >> print 't_block2=',t_block2 >> >> print 't_block3=',t_block3 >> >> >> The output for the code is the following: >> >> M_dimension= 512 >> R_dimension= 262144 >> t_block1= 4.25343304805 >> t_block2= 3.88635510938 >> t_block3= 0.487477319045 >> >> >> Then it is faster to work with R than M, even though R is bigger. >> >> Some suggestions for speed up pywin32 code in this example? >> >> >> Best Regards, >> >> Daniel Pose. >> >> >> >> >> >> >> _______________________________________________ >> 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 iinjdpa at gmail.com Sun May 13 14:09:46 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Sun, 13 May 2012 14:09:46 +0200 Subject: [python-win32] speed up win32com.client In-Reply-To: <4FAF1DE5.7080903@skippinet.com.au> References: <4FA94D99.2000404@probo.com> <4FADDAAE.5070500@gmail.com> <4FAF1DE5.7080903@skippinet.com.au> Message-ID: Thank you Mark, I will try to use win32com.client.CastTo() because InsertionPoint attribute is not inside IAcadEntity. Opss, you are right, the problem was TEMP\gen_py folder. Thank you! 2012/5/13 Mark Hammond > On 13/05/2012 5:00 AM, DANIEL POSE wrote: > >> I had tried to change attribute name in several ways (InsertionPoint, >> insertionPoint, insertionpoint,...) but I obtained the same error: >> >> Traceback (most recent call last): >> File "", line 1, in >> File >> "C:\Python27\lib\site-**packages\spyderlib\widgets\** >> externalshell\startup.py", >> line 128, in runfile >> execfile(filename, glbs) >> File "C:\Documents and Settings\Usuario\Mis >> documentos\Dropbox\PYTHON\**PruebaAutoCAD.py", line 29, in >> M.append(objeto.**insertionpoint) >> File "C:\Python27\lib\site-**packages\win32com\client\__**init__.py", >> line 465, in __getattr__ >> raise AttributeError("'%s' object has no attribute '%s'" % >> (repr(self), attr)) >> AttributeError: '> instance at 0x88940672>' object has no attribute 'insertionpoint' >> > > In the gen_py directory you should find a generated file supporting the > AutoCAD object - it will have a GUID in its name so it might not be obvious > which one applies, but inside that you should find the 'IAcadEntity' > object. That should have a _prop_map_get attribute which lists the > attributes available on the object - I'd expect to find insertionPoint > listed there. It may turn out it is actually on a different object, in > which case the win32com.client.CastTo() function might be useful to get the > appropriate interface. > > > If I delete only the win32com\client\gen_py folder It doesn't work. I >> need delete for example win32com and win32 folders and restore older ones. >> > > Hrm - I certainly can't explain that! Or maybe I can - check your %TEMP% > folder and see if there is a gen_py directory there? > > Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iinjdpa at gmail.com Sun May 13 20:19:50 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Sun, 13 May 2012 20:19:50 +0200 Subject: [python-win32] speed up win32com.client In-Reply-To: <4FAF1DE5.7080903@skippinet.com.au> References: <4FA94D99.2000404@probo.com> <4FADDAAE.5070500@gmail.com> <4FAF1DE5.7080903@skippinet.com.au> Message-ID: Just for conclude the discusion, the solution is win32.client.CastTo() as Mark said. However, this modification doesn't speed up the code (at least in my case). Then, perhaps I need to learn C++ in order to embed python inside AutoCAD as Dan Glassman said. But, not now... Here I post the code using CastTo: import win32com.client import time import string import random def nombrealeatorio(size=10, chars=string.ascii_uppercase + string.digits): '''Esta funci?n crea un nombre aleatorio de 10 caracteres''' return ''.join(random.choice(chars) for x in range(size)) t1=time.clock() acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") doc=win32com.client.CastTo(acad,"IAcadApplication") doc = acad.ActiveDocument seleccion=win32com.client.CastTo(doc,"IAcadSelectionSets") seleccion=doc.SelectionSets.Add(nombrealeatorio()) seleccion=win32com.client.CastTo(seleccion,"IAcadSelectionSet") seleccion.SelectOnScreen() t2=time.clock() M=[] for objeto in seleccion: objeto=win32com.client.CastTo(objeto, "IAcadBlockReference") if objeto.ObjectName=='AcDbBlockReference': M.append(objeto.InsertionPoint) t3=time.clock() print 'M_dimension=',len(M) R=[] for m in M: for x in M: R.append(max(m)+max(x)) print 'R_dimension=',len(R) t4=time.clock() t_block1=t2-t1 t_block2=t3-t2 t_block3=t4-t3 print 't_block1=',t_block1 print 't_block2=',t_block2 print 't_block3=',t_block3 print 't_total=',t4-t1 timing using early-binding: M_dimension= 512 R_dimension= 262144 t_block1= 3.46952811042 t_block2= 4.81084020455 t_block3= 0.49030086226 t_total= 8.77066917723 timing using late-binding: M_dimension= 512 R_dimension= 262144 t_block1= 3.20033803179 t_block2= 4.96431445896 t_block3= 0.570101227949 t_total= 8.7347537187 Thank you for this wonderfull mailing list and pywin32. 2012/5/13 Mark Hammond > On 13/05/2012 5:00 AM, DANIEL POSE wrote: > >> I had tried to change attribute name in several ways (InsertionPoint, >> insertionPoint, insertionpoint,...) but I obtained the same error: >> >> Traceback (most recent call last): >> File "", line 1, in >> File >> "C:\Python27\lib\site-**packages\spyderlib\widgets\** >> externalshell\startup.py", >> line 128, in runfile >> execfile(filename, glbs) >> File "C:\Documents and Settings\Usuario\Mis >> documentos\Dropbox\PYTHON\**PruebaAutoCAD.py", line 29, in >> M.append(objeto.**insertionpoint) >> File "C:\Python27\lib\site-**packages\win32com\client\__**init__.py", >> line 465, in __getattr__ >> raise AttributeError("'%s' object has no attribute '%s'" % >> (repr(self), attr)) >> AttributeError: '> instance at 0x88940672>' object has no attribute 'insertionpoint' >> > > In the gen_py directory you should find a generated file supporting the > AutoCAD object - it will have a GUID in its name so it might not be obvious > which one applies, but inside that you should find the 'IAcadEntity' > object. That should have a _prop_map_get attribute which lists the > attributes available on the object - I'd expect to find insertionPoint > listed there. It may turn out it is actually on a different object, in > which case the win32com.client.CastTo() function might be useful to get the > appropriate interface. > > > If I delete only the win32com\client\gen_py folder It doesn't work. I >> need delete for example win32com and win32 folders and restore older ones. >> > > Hrm - I certainly can't explain that! Or maybe I can - check your %TEMP% > folder and see if there is a gen_py directory there? > > Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iinjdpa at gmail.com Sun May 13 20:28:26 2012 From: iinjdpa at gmail.com (DANIEL POSE) Date: Sun, 13 May 2012 20:28:26 +0200 Subject: [python-win32] speed up win32com.client In-Reply-To: References: <4FA94D99.2000404@probo.com> <4FADDAAE.5070500@gmail.com> <4FAF1DE5.7080903@skippinet.com.au> Message-ID: Sorry!!! my mistake!!! really there are a speed up, the timing using late-binding is: M_dimension= 512 R_dimension= 262144 t_block1= 3.00059867944 t_block2= 12.2370913063 t_block3= 0.488927223991 t_total= 15.7266172097 Then it is about half time using early-binding for my example. It is wonderfull!! 2012/5/13 DANIEL POSE > Just for conclude the discusion, the solution is win32.client.CastTo() as > Mark said. However, this modification doesn't speed up the code (at least > in my case). > Then, perhaps I need to learn C++ in order to embed python inside AutoCAD > as Dan Glassman said. But, not now... > Here I post the code using CastTo: > > > > import win32com.client > > import time > > import string > > import random > > > def nombrealeatorio(size=10, chars=string.ascii_uppercase + > string.digits): > > '''Esta funci?n crea un nombre aleatorio de 10 caracteres''' > > return ''.join(random.choice(chars) for x in range(size)) > > t1=time.clock() > > > acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application") > > doc=win32com.client.CastTo(acad,"IAcadApplication") > > doc = acad.ActiveDocument > > seleccion=win32com.client.CastTo(doc,"IAcadSelectionSets") > > seleccion=doc.SelectionSets.Add(nombrealeatorio()) > > seleccion=win32com.client.CastTo(seleccion,"IAcadSelectionSet") > > seleccion.SelectOnScreen() > > > t2=time.clock() > > M=[] > > for objeto in seleccion: > > objeto=win32com.client.CastTo(objeto, "IAcadBlockReference") > > if objeto.ObjectName=='AcDbBlockReference': > > M.append(objeto.InsertionPoint) > > t3=time.clock() > > print 'M_dimension=',len(M) > > R=[] > > for m in M: > > for x in M: > > R.append(max(m)+max(x)) > > print 'R_dimension=',len(R) > > t4=time.clock() > > t_block1=t2-t1 > > t_block2=t3-t2 > > t_block3=t4-t3 > > print 't_block1=',t_block1 > > print 't_block2=',t_block2 > > print 't_block3=',t_block3 > > print 't_total=',t4-t1 > > > > > > timing using early-binding: > > M_dimension= 512 > > R_dimension= 262144 > > t_block1= 3.46952811042 > > t_block2= 4.81084020455 > > t_block3= 0.49030086226 > > t_total= 8.77066917723 > > > timing using late-binding: > > M_dimension= 512 > > R_dimension= 262144 > > t_block1= 3.20033803179 > > t_block2= 4.96431445896 > > t_block3= 0.570101227949 > > t_total= 8.7347537187 > > > Thank you for this wonderfull mailing list and pywin32. > > > 2012/5/13 Mark Hammond > >> On 13/05/2012 5:00 AM, DANIEL POSE wrote: >> >>> I had tried to change attribute name in several ways (InsertionPoint, >>> insertionPoint, insertionpoint,...) but I obtained the same error: >>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> File >>> "C:\Python27\lib\site-**packages\spyderlib\widgets\** >>> externalshell\startup.py", >>> line 128, in runfile >>> execfile(filename, glbs) >>> File "C:\Documents and Settings\Usuario\Mis >>> documentos\Dropbox\PYTHON\**PruebaAutoCAD.py", line 29, in >>> M.append(objeto.**insertionpoint) >>> File "C:\Python27\lib\site-**packages\win32com\client\__**init__.py", >>> line 465, in __getattr__ >>> raise AttributeError("'%s' object has no attribute '%s'" % >>> (repr(self), attr)) >>> AttributeError: '>> instance at 0x88940672>' object has no attribute 'insertionpoint' >>> >> >> In the gen_py directory you should find a generated file supporting the >> AutoCAD object - it will have a GUID in its name so it might not be obvious >> which one applies, but inside that you should find the 'IAcadEntity' >> object. That should have a _prop_map_get attribute which lists the >> attributes available on the object - I'd expect to find insertionPoint >> listed there. It may turn out it is actually on a different object, in >> which case the win32com.client.CastTo() function might be useful to get the >> appropriate interface. >> >> >> If I delete only the win32com\client\gen_py folder It doesn't work. I >>> need delete for example win32com and win32 folders and restore older >>> ones. >>> >> >> Hrm - I certainly can't explain that! Or maybe I can - check your %TEMP% >> folder and see if there is a gen_py directory there? >> >> Mark >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Mon May 14 03:07:19 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 14 May 2012 11:07:19 +1000 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 In-Reply-To: References: Message-ID: <4FB05AC7.6060000@gmail.com> You haven't given us enough information to help. What error do you see? What is the most recent combination of Python and pywin32 that works? Mark On 12/05/2012 10:31 PM, EdShallow wrote: > Hi Folks, > > I have an ActiveX COM dll generated by VisualBasic 6 in WinXP. I > can call it and use it successfully with Python 2.3 and pywin32-208 > without problems. > > As soon as I upgrade either pywin32- or Python to anything itself > to anything newer, my dll throws an exception immediately upon entry. > > Can anyone point me in a general direction with respect to > addressing this incompatibility? > > Thanks, > Ed > > -- > Ed's Contact Information: > Mobile Phone: 613-852-6410 > Gmail: ed.shallow at gmail.com > VOIP Address: 107529 at sip.ca1.voip.ms > VOIP DID#: 613-458-5004 > Skype ID: edward.shallow > Home Phone: 613-482-2090 > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From antonyjoseph89 at gmail.com Mon May 14 14:23:01 2012 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Mon, 14 May 2012 17:53:01 +0530 Subject: [python-win32] Windows service using py2exe Message-ID: Hi all, I converted my python project to a service. When using the usual options of install and start/stop, everything works correctly. When I compile the project using py2exe, >test.exe install Installing service test >test.exe start Starting service test - But it not actually get started When i run it in debug mode, >test.exe debug Starting service Test C:\Documents and Settings\admin\Desktop>test.exe debug Debugging service Test - press Ctrl+C to stop. Traceback (most recent call last): File "boot_service.py", line 185, in File "win32serviceutil.pyc", line 611, in HandleCommandLine File "win32serviceutil.pyc", line 447, in DebugService File "test.pyc", line 28, in __init__ WindowsError: [Error 267] The directory name is invalid: 'C:\\Documents and Settings\\admin\\Desktop\\sharefolder\\test.e xe' Code: test = Target( description = 'Test Service', modules = ['test'], cmdline_style='pywin32' ) setup( options = {"py2exe": {"compressed": 1, "bundle_files": 1, "ascii": 1, "packages": ["encodings"]} }, console=["test.py"], zipfile = None, service=[test] ) From haraldarminmassa at gmail.com Mon May 14 14:26:32 2012 From: haraldarminmassa at gmail.com (Harald Armin Massa[legacy]) Date: Mon, 14 May 2012 14:26:32 +0200 Subject: [python-win32] Windows service using py2exe In-Reply-To: References: Message-ID: Antony, > C:\Documents and Settings\admin\Desktop>test.exe debug > Debugging service Test - press Ctrl+C to stop. > Traceback (most recent call last): > ?File "boot_service.py", line 185, in > ?File "win32serviceutil.pyc", line 611, in HandleCommandLine > ?File "win32serviceutil.pyc", line 447, in DebugService > ?File "test.pyc", line 28, in __init__ > WindowsError: [Error 267] The directory name is invalid: > 'C:\\Documents and Settings\\admin\\Desktop\\sharefolder\\test.e > xe' services get run with windows-system directory as current directory. Most likely there are no access rights to admins user directory. As a first approach put your exe somewhere else then on the desktop. Harald -- LightningTalkMan a brand of GHUM GmbH Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 From mhammond at skippinet.com.au Mon May 14 14:50:40 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 14 May 2012 22:50:40 +1000 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 In-Reply-To: References: <4FB05AC7.6060000@gmail.com> Message-ID: <4FB0FFA0.6070109@skippinet.com.au> [re-adding python-win32 - please keep replies on list] On 14/05/2012 10:39 PM, EdShallow wrote: > Hi Mark, > > Python 2.3 with pywin32-208 works. The error I receive reads > "Object through and exception at line 3". How do you get that error? You say "my dll throws an exception immediately upon entry" - I can't reconcile that "with the error I receive". What does Python do when calling your failing DLL? (ie, do you get a traceback? If so, please include it completely. If not, what result does Python get? I'm still very unclear on the context of your problem. > Un-registering and re-registering the dll does not help. But that's just unregistering and re-registering your DLL right? > The test was conducted on the same machine after uninstalling > Python and re-installing numerous combinations of Python 2.4, 2.5, 2.6, > 2.7 with associated pywin32-208 thry pywin32-214. > > If I uninstall the newer Python and re-install Python 2.3 and > pywin32-208 all is OK again. It is definitely environmental as opposed > to the code. Well - it's *someone's* code :) To be clear, 2.3 + pywin32 209 fails? Mark > > Thanks, > Ed > > On Sun, May 13, 2012 at 9:07 PM, Mark Hammond > wrote: > > You haven't given us enough information to help. What error do you > see? What is the most recent combination of Python and pywin32 that > works? > > Mark > > > On 12/05/2012 10:31 PM, EdShallow wrote: > > Hi Folks, > > I have an ActiveX COM dll generated by VisualBasic 6 in > WinXP. I > can call it and use it successfully with Python 2.3 and pywin32-208 > without problems. > > As soon as I upgrade either pywin32- or Python to anything > itself > to anything newer, my dll throws an exception immediately upon > entry. > > Can anyone point me in a general direction with respect to > addressing this incompatibility? > > Thanks, > Ed > > -- > Ed's Contact Information: > Mobile Phone: 613-852-6410 > Gmail: ed.shallow at gmail.com > > > VOIP Address: 107529 at sip.ca1.voip.ms > __> > > VOIP DID#: 613-458-5004 > Skype ID: edward.shallow > Home Phone: 613-482-2090 > > > > _________________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/__mailman/listinfo/python-win32 > > > > > > > > -- > Ed's Contact Information: > Mobile Phone: 613-852-6410 > Gmail: ed.shallow at gmail.com > VOIP Address: 107529 at sip.ca1.voip.ms > VOIP DID#: 613-458-5004 > Skype ID: edward.shallow > Home Phone: 613-482-2090 > From ed.shallow at gmail.com Mon May 14 15:00:56 2012 From: ed.shallow at gmail.com (EdShallow) Date: Mon, 14 May 2012 09:00:56 -0400 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 In-Reply-To: <4FB0FFA0.6070109@skippinet.com.au> References: <4FB05AC7.6060000@gmail.com> <4FB0FFA0.6070109@skippinet.com.au> Message-ID: Thanks Mark, I will get you the details you request later today. Thanks for the help. Ed On Mon, May 14, 2012 at 8:50 AM, Mark Hammond wrote: > [re-adding python-win32 - please keep replies on list] > > > On 14/05/2012 10:39 PM, EdShallow wrote: > >> Hi Mark, >> >> Python 2.3 with pywin32-208 works. The error I receive reads >> "Object through and exception at line 3". >> > > How do you get that error? You say "my dll throws an exception > immediately upon entry" - I can't reconcile that "with the error I > receive". What does Python do when calling your failing DLL? (ie, do you > get a traceback? If so, please include it completely. If not, what result > does Python get? I'm still very unclear on the context of your problem. > > > Un-registering and re-registering the dll does not help. >> > > But that's just unregistering and re-registering your DLL right? > > > The test was conducted on the same machine after uninstalling >> Python and re-installing numerous combinations of Python 2.4, 2.5, 2.6, >> 2.7 with associated pywin32-208 thry pywin32-214. >> >> If I uninstall the newer Python and re-install Python 2.3 and >> pywin32-208 all is OK again. It is definitely environmental as opposed >> to the code. >> > > Well - it's *someone's* code :) To be clear, 2.3 + pywin32 209 fails? > > Mark > >> >> Thanks, >> Ed >> >> On Sun, May 13, 2012 at 9:07 PM, Mark Hammond > >> wrote: >> >> You haven't given us enough information to help. What error do you >> see? What is the most recent combination of Python and pywin32 that >> works? >> >> Mark >> >> >> On 12/05/2012 10:31 PM, EdShallow wrote: >> >> Hi Folks, >> >> I have an ActiveX COM dll generated by VisualBasic 6 in >> WinXP. I >> can call it and use it successfully with Python 2.3 and pywin32-208 >> without problems. >> >> As soon as I upgrade either pywin32- or Python to anything >> itself >> to anything newer, my dll throws an exception immediately upon >> entry. >> >> Can anyone point me in a general direction with respect to >> addressing this incompatibility? >> >> Thanks, >> Ed >> >> -- >> Ed's Contact Information: >> Mobile Phone: 613-852-6410 >> Gmail: ed.shallow at gmail.com >> > >> VOIP Address: 107529 at sip.ca1.voip.ms >> > __> >> >> VOIP DID#: 613-458-5004 >> Skype ID: edward.shallow >> Home Phone: 613-482-2090 >> >> >> >> ______________________________**___________________ >> python-win32 mailing list >> python-win32 at python.org >> > >> http://mail.python.org/__**mailman/listinfo/python-win32 >> >> >> > >> >> >> >> >> >> >> -- >> Ed's Contact Information: >> Mobile Phone: 613-852-6410 >> Gmail: ed.shallow at gmail.com >> VOIP Address: 107529 at sip.ca1.voip.ms >> VOIP DID#: 613-458-5004 >> Skype ID: edward.shallow >> Home Phone: 613-482-2090 >> >> > > -- Ed's Contact Information: Mobile Phone: 613-852-6410 Gmail: ed.shallow at gmail.com VOIP Address: 107529 at sip.ca1.voip.ms VOIP DID#: 613-458-5004 Skype ID: edward.shallow Home Phone: 613-482-2090 -------------- next part -------------- An HTML attachment was scrubbed... URL: From haraldarminmassa at gmail.com Tue May 15 11:27:45 2012 From: haraldarminmassa at gmail.com (Harald Armin Massa[legacy]) Date: Tue, 15 May 2012 11:27:45 +0200 Subject: [python-win32] Windows service using py2exe In-Reply-To: References: Message-ID: Hello Antony, please keep discussion on the list, so it may serve as a later reference for others with similiar problems. 2012/5/14 Antony Joseph : > Hi, > > Thanks a lot for your quick response. > > I tried, I get the same result > > C:\Service>test.exe install > Installing service Test > Service installed > > C:\Service>test.exe start > Starting service Test > > C:\Service>test.exe debug > Debugging service Test - press Ctrl+C to stop. > Traceback (most recent call last): > ?File "boot_service.py", line 185, in > ?File "win32serviceutil.pyc", line 611, in HandleCommandLine > ?File "win32serviceutil.pyc", line 447, in DebugService > ?File "test.pyc", line 28, in __init__ > WindowsError: [Error 267] The directory name is invalid: 'C:\\Service\\test.exe' > > > On 14 May 2012 17:56, Harald Armin Massa[legacy] > wrote: >> Antony, >> >>> C:\Documents and Settings\admin\Desktop>test.exe debug >>> Debugging service Test - press Ctrl+C to stop. >>> Traceback (most recent call last): >>> ?File "boot_service.py", line 185, in >>> ?File "win32serviceutil.pyc", line 611, in HandleCommandLine >>> ?File "win32serviceutil.pyc", line 447, in DebugService >>> ?File "test.pyc", line 28, in __init__ >>> WindowsError: [Error 267] The directory name is invalid: >>> 'C:\\Documents and Settings\\admin\\Desktop\\sharefolder\\test.e >>> xe' Please check: what ishappining in line 28 of your test.py ? why is the application trying to access the desktop? Harald -- LightningTalkMan a brand of GHUM GmbH Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 From page3d at gmail.com Thu May 17 19:01:18 2012 From: page3d at gmail.com (David L. Page) Date: Thu, 17 May 2012 13:01:18 -0400 Subject: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File In-Reply-To: References: Message-ID: Hi, I have an .sdf file (SQL CE 3.5) that someone has given me. I need to extract some data from the file (and will need to extract similar data from similar files in the future). I'm trying to write a python script to do it. The DB file has a table (Profiles) with three items (DataID (int), Data (varbinary[8000], CreationDate(datetime)). I am having a problem accessing the varbinary data in Data. Here's a code snippet that works for the CreationDate. ==== Begin Code (test.py) ==== import adodbapi file = "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf" connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % file conn = adodbapi.connect(connstr) cur = conn.cursor() sql = "select CreationDate from Profiles where DataID = 2" cur.execute(sql) result = cur.fetchall() for item in result: print item cur.close() conn.close() ==== End Code ==== ==== Begin Output ==== D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data S ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;" adodbapi New connection at 2C034F0 adodbapi New cursor at 2C03B50 on conn 2C034F0 Executing command="select CreationDate from Profiles where DataID = 2" ('2012-01-18 10:54:19.843000',) adodbapi Closed connection at 2C034F0 ==== End Output ==== That code snippet accesses the date just fine. However, when I try to access the Data by changing the select command: sql = "select CreationDate from Profiles where DataID = 2" I get the following error. ==== Begin Output2 ==== D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data S ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf" adodbapi New connection at 2C834F0 adodbapi New cursor at 2C83B50 on conn 2C834F0 Executing command="select Data from Profiles where DataID = 2" Traceback (most recent call last): File "test.py", line 9, in cur.execute(sql) File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, in execu te self._execute_command() File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in _execu te_command self._raiseCursorError(klass, _message) File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in _raise CursorError eh(self.connection,self,errorclass,errorvalue) File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in standa rdErrorHandler raise errorclass(errorvalue) adodbapi.adodbapi.DatabaseError: (-2147352567, 'Exception occurred.', (0, u'Micr osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB operation gene rated errors. Check each OLE DB status value, if available. No work was done.', None, 0, -2147217887), None) Command: select Data from Profiles where DataID = 2 Parameters: [] adodbapi Closed connection at 2C834F0 ==== End Output2 ==== Any help you could provide would be greatly appreciated. Thanks. --Dave PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation. -- David L. Page davidpage at ieee.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Thu May 17 20:59:09 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 17 May 2012 12:59:09 -0600 Subject: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File In-Reply-To: References: Message-ID: David: You do not mention the version of adodbapi you are using. >>>import adodbapi >>>print adodbapi.version 2.4.2.2 is current. Some older versions have known problems with large binary fields -- which is just exactly what you are using. Please try again with a current version if you have not done that. If that does not do the trick, then there is yet another bug to chase... download from http://sourceforge.net/projects/adodbapi or get the latest pywin32. -- Vernon Cole On Thu, May 17, 2012 at 11:01 AM, David L. Page wrote: > > Hi, > > I have an .sdf file (SQL CE 3.5) that someone has given me. I need to > extract some data from the file (and will need to extract similar data from > similar files in the future). I'm trying to write a python script to do it. > > The DB file has a table (Profiles) with three items (DataID (int), Data > (varbinary[8000], CreationDate(datetime)). I am having a problem accessing > the varbinary data in Data. Here's a code snippet that works for the > CreationDate. > > ==== Begin Code (test.py) ==== > import adodbapi > > file = > "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf" > connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % > file > conn = adodbapi.connect(connstr) > cur = conn.cursor() > sql = "select CreationDate from Profiles where DataID = 2" > cur.execute(sql) > result = cur.fetchall() > for item in result: > print item > cur.close() > conn.close() > ==== End Code ==== > > ==== Begin Output ==== > > D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py > adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; > Data S > ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;" > adodbapi New connection at 2C034F0 > adodbapi New cursor at 2C03B50 on conn 2C034F0 > Executing command="select CreationDate from Profiles where DataID = 2" > ('2012-01-18 10:54:19.843000',) > adodbapi Closed connection at 2C034F0 > > ==== End Output ==== > > That code snippet accesses the date just fine. > > However, when I try to access the Data by changing the select command: > > sql = "select CreationDate from Profiles where DataID = 2" > > I get the following error. > > ==== Begin Output2 ==== > > D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py > adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; > Data S > ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf" > adodbapi New connection at 2C834F0 > adodbapi New cursor at 2C83B50 on conn 2C834F0 > Executing command="select Data from Profiles where DataID = 2" > Traceback (most recent call last): > File "test.py", line 9, in > cur.execute(sql) > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, in > execu > te > self._execute_command() > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in > _execu > te_command > self._raiseCursorError(klass, _message) > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in > _raise > CursorError > eh(self.connection,self,errorclass,errorvalue) > File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in > standa > rdErrorHandler > raise errorclass(errorvalue) > adodbapi.adodbapi.DatabaseError: (-2147352567, 'Exception occurred.', (0, > u'Micr > osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB > operation gene > rated errors. Check each OLE DB status value, if available. No work was > done.', > None, 0, -2147217887), None) > Command: > select Data from Profiles where DataID = 2 > Parameters: > [] > adodbapi Closed connection at 2C834F0 > > ==== End Output2 ==== > > Any help you could provide would be greatly appreciated. Thanks. > > --Dave > > PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation. > > > > > -- > David L. Page > davidpage at ieee.org > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Thu May 17 21:02:34 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 17 May 2012 13:02:34 -0600 Subject: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File In-Reply-To: References: Message-ID: My error! Reading again, I see that your version is up to date. If the data is not private, could you send a zipped copy of your data file to me directly (not to the list)? -- Vernon On Thu, May 17, 2012 at 12:59 PM, Vernon Cole wrote: > David: > You do not mention the version of adodbapi you are using. > >>>import adodbapi > >>>print adodbapi.version > > 2.4.2.2 is current. Some older versions have known problems with large > binary fields -- which is just exactly what you are using. > Please try again with a current version if you have not done that. If that > does not do the trick, then there is yet another bug to chase... > download from http://sourceforge.net/projects/adodbapi or get the latest > pywin32. > > -- > Vernon Cole > > On Thu, May 17, 2012 at 11:01 AM, David L. Page wrote: > >> >> Hi, >> >> I have an .sdf file (SQL CE 3.5) that someone has given me. I need to >> extract some data from the file (and will need to extract similar data from >> similar files in the future). I'm trying to write a python script to do it. >> >> The DB file has a table (Profiles) with three items (DataID (int), Data >> (varbinary[8000], CreationDate(datetime)). I am having a problem accessing >> the varbinary data in Data. Here's a code snippet that works for the >> CreationDate. >> >> ==== Begin Code (test.py) ==== >> import adodbapi >> >> file = >> "D:\\Not_Synced\\Code\\GetProfile\\20120516_111500\\ProfileDB.1.1.sdf" >> connstr = 'Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=%s;' % >> file >> conn = adodbapi.connect(connstr) >> cur = conn.cursor() >> sql = "select CreationDate from Profiles where DataID = 2" >> cur.execute(sql) >> result = cur.fetchall() >> for item in result: >> print item >> cur.close() >> conn.close() >> ==== End Code ==== >> >> ==== Begin Output ==== >> >> D:\Not_Synced\Code\GetProfile\20120516_111500>python test.py >> adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; >> Data S >> ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf;" >> adodbapi New connection at 2C034F0 >> adodbapi New cursor at 2C03B50 on conn 2C034F0 >> Executing command="select CreationDate from Profiles where DataID = 2" >> ('2012-01-18 10:54:19.843000',) >> adodbapi Closed connection at 2C034F0 >> >> ==== End Output ==== >> >> That code snippet accesses the date just fine. >> >> However, when I try to access the Data by changing the select command: >> >> sql = "select CreationDate from Profiles where DataID = 2" >> >> I get the following error. >> >> ==== Begin Output2 ==== >> >> D:\Not_Synced\Code\GetProfile\20120516_111500>python test2.py >> adodbapi v2.4.2.2 attempting: "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; >> Data S >> ource=D:\Not_Synced\Code\GetProfile\20120516_111500\ProfilesDB.1.1.sdf" >> adodbapi New connection at 2C834F0 >> adodbapi New cursor at 2C83B50 on conn 2C834F0 >> Executing command="select Data from Profiles where DataID = 2" >> Traceback (most recent call last): >> File "test.py", line 9, in >> cur.execute(sql) >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1008, >> in execu >> te >> self._execute_command() >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 893, in >> _execu >> te_command >> self._raiseCursorError(klass, _message) >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 758, in >> _raise >> CursorError >> eh(self.connection,self,errorclass,errorvalue) >> File "e:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 107, in >> standa >> rdErrorHandler >> raise errorclass(errorvalue) >> adodbapi.adodbapi.DatabaseError: (-2147352567, 'Exception occurred.', >> (0, u'Micr >> osoft SQL Server Compact OLE DB Provider', u'Multiple-step OLE DB >> operation gene >> rated errors. Check each OLE DB status value, if available. No work was >> done.', >> None, 0, -2147217887), None) >> Command: >> select Data from Profiles where DataID = 2 >> Parameters: >> [] >> adodbapi Closed connection at 2C834F0 >> >> ==== End Output2 ==== >> >> Any help you could provide would be greatly appreciated. Thanks. >> >> --Dave >> >> PS I'm using Win7 x64 with a Python 2.7 (32 bit) installation. >> >> >> >> >> -- >> David L. Page >> davidpage at ieee.org >> >> >> _______________________________________________ >> 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 page3d at gmail.com Thu May 17 23:12:06 2012 From: page3d at gmail.com (David L. Page) Date: Thu, 17 May 2012 17:12:06 -0400 Subject: [python-win32] Fwd: Trouble with SQL CE 3.5 DB File In-Reply-To: References: Message-ID: Update: I have put together some C# code and I'm able to see the varbinary Data using the MS Visual C# System.Data.SqlServerCe calls. (I am by no means a C# or SQLCE expert. I just thought I'd try another avenue.) I can supply the C# code if desired, but here's the SQL select call that retrieves what I need: using (SqlCeCommand com = new SqlCeCommand("SELECT Data FROM Profiles WHERE DataID=2", con)) Does the mean there's a problem in adodbapi for varbinary(max) data? --Dave -- David L. Page davidpage at ieee.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From atrick at tri-tech.com Fri May 18 01:00:30 2012 From: atrick at tri-tech.com (Alan Trick) Date: Thu, 17 May 2012 16:00:30 -0700 Subject: [python-win32] Adding a notification icon from a service Message-ID: Hi, I have two smallish python modules, one which runs a service, and the other which puts a notification icon with a trivial menu on the windows panel (these modules are quite similar to existing examples in pywin32). Both of these modules work fine by themselves. However when I try to create the notification module from the service, I get troubles. I'm starting the service using win32serviceutil.HandleCommandLine, and it works fine in debug mode (as long as I'm running as Administrator), but when I try to start it, the notification code fails and it won't add the icon; and when I try to stop it, it wont' stop and just hangs. The main problem that I can identify right now is that my calls to win32gui.Shell_NotifyIcon fails. It raises a pywintypes.error(0, 'Shell_NotifyIcon', 'No error message is available'). Does anybody know what this means, or have any idea how to figure out what it means? From skippy.hammond at gmail.com Fri May 18 03:20:02 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 18 May 2012 11:20:02 +1000 Subject: [python-win32] Adding a notification icon from a service In-Reply-To: References: Message-ID: <4FB5A3C2.8010207@gmail.com> On 18/05/2012 9:00 AM, Alan Trick wrote: > Hi, > > I have two smallish python modules, one which runs a service, and the > other which puts a notification icon with a trivial menu on the > windows panel (these modules are quite similar to existing examples in > pywin32). Both of these modules work fine by themselves. However when > I try to create the notification module from the service, I get > troubles. I'm starting the service using > win32serviceutil.HandleCommandLine, and it works fine in debug mode > (as long as I'm running as Administrator), but when I try to start it, > the notification code fails and it won't add the icon; and when I try > to stop it, it wont' stop and just hangs. > > The main problem that I can identify right now is that my calls to > win32gui.Shell_NotifyIcon fails. It raises a pywintypes.error(0, > 'Shell_NotifyIcon', 'No error message is available'). Does anybody > know what this means, or have any idea how to figure out what it > means? Services don't have access to the desktop which is there the notification bar lives. The usual way to implement this is with 2 processes - one for the service and one for the taskbar, and to implement some kind of RPC between them, such as a named pipe - one of the service samples uses a named pipe so that should get you started. HTH, Mark From ed.shallow at gmail.com Sat May 19 17:22:32 2012 From: ed.shallow at gmail.com (EdShallow) Date: Sat, 19 May 2012 11:22:32 -0400 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 In-Reply-To: <4FB0FFA0.6070109@skippinet.com.au> References: <4FB05AC7.6060000@gmail.com> <4FB0FFA0.6070109@skippinet.com.au> Message-ID: Hi Mark, After much more testing here is some more to go on: Background again: - I have a VisualBasic-generated ActiveX COM object called capiCrypto.clsCrypto - I call it like this clsCrypto = win32com.client.Dispatch("capiCrypto.clsCrypto") clsCrypto.InStringBuffer = newCert clsCrypto.CRLFileName = self.Request.FqdnCRL result = clsCrypto.CheckCertBufferAgainstCRLFile() - it was generated on WinXP SP2 - It can successfully be called from Python 2.3 win32-208 without problem - As soon as I upgrade to Python 2.7 I get this stack trace without touching the dll or its registration 2012/05/19 10:18:12 INFO Traceback (most recent call last): File "cherrypy\_cphttptools.pyo", line 271, in run File "cherrypy\_cphttptools.pyo", line 502, in main File "checkcertcrld.pyw", line 113, in crlHandler File "CrlDispatch.pyo", line 121, in handle File "CheckCertCrl.pyo", line 38, in execute File "", line 3, in CheckCertBufferAgainstCRLFile com_error: (-2147417851, 'The server threw an exception.', None, None) Now here is some strange feedback . . . - Knowing that everything was OK with Python 2.3, I isolated the above code in its own HTTP process and py2exe'ed it thinking py2exe would preserve the whole 2.3 call environment - My thought was I would call the HTTP daemon which was packaged with 2.3 and 208 from my 2.7 environment both in their own py2exe-created exe's one in 2.7 the other in 2.3 - So check this, the very first call to the dll in the 2.3 exe from the 2.7 exe worked !!! Then all successive calls failed ???? - here is the log: 2012/05/19 08:53:28 INFO CheckCertCRL completed with TransactionStatus ===> 1763 and TransactionStatusString ==> Certificate Revocation Check failed Current time is NOT within the CRL validity period 2012/05/19 10:18:12 HTTP INFO 127.0.0.1 - POST /crlHandler HTTP/1.1 2012/05/19 10:18:12 INFO Traceback (most recent call last): File "cherrypy\_cphttptools.pyo", line 271, in run File "cherrypy\_cphttptools.pyo", line 502, in main File "checkcertcrld.pyw", line 113, in crlHandler File "CrlDispatch.pyo", line 121, in handle File "CheckCertCrl.pyo", line 38, in execute File "", line 3, in CheckCertBufferAgainstCRLFile com_error: (-2147417851, 'The server threw an exception.', None, None) - Note the first call which successfully checked the revocation status of a certificate and returned a 1763 indicating a successful call to the COM dll (although the cert check failed) - Every subsequent time I called the dll it fails ??? - Something happened in the environment after the first call and I have no clue ??? Ed On Mon, May 14, 2012 at 8:50 AM, Mark Hammond wrote: > [re-adding python-win32 - please keep replies on list] > > > On 14/05/2012 10:39 PM, EdShallow wrote: > >> Hi Mark, >> >> Python 2.3 with pywin32-208 works. The error I receive reads >> "Object through and exception at line 3". >> > > How do you get that error? You say "my dll throws an exception > immediately upon entry" - I can't reconcile that "with the error I > receive". What does Python do when calling your failing DLL? (ie, do you > get a traceback? If so, please include it completely. If not, what result > does Python get? I'm still very unclear on the context of your problem. > > > Un-registering and re-registering the dll does not help. >> > > But that's just unregistering and re-registering your DLL right? > > > The test was conducted on the same machine after uninstalling >> Python and re-installing numerous combinations of Python 2.4, 2.5, 2.6, >> 2.7 with associated pywin32-208 thry pywin32-214. >> >> If I uninstall the newer Python and re-install Python 2.3 and >> pywin32-208 all is OK again. It is definitely environmental as opposed >> to the code. >> > > Well - it's *someone's* code :) To be clear, 2.3 + pywin32 209 fails? > > Mark > >> >> Thanks, >> Ed >> >> On Sun, May 13, 2012 at 9:07 PM, Mark Hammond > >> wrote: >> >> You haven't given us enough information to help. What error do you >> see? What is the most recent combination of Python and pywin32 that >> works? >> >> Mark >> >> >> On 12/05/2012 10:31 PM, EdShallow wrote: >> >> Hi Folks, >> >> I have an ActiveX COM dll generated by VisualBasic 6 in >> WinXP. I >> can call it and use it successfully with Python 2.3 and pywin32-208 >> without problems. >> >> As soon as I upgrade either pywin32- or Python to anything >> itself >> to anything newer, my dll throws an exception immediately upon >> entry. >> >> Can anyone point me in a general direction with respect to >> addressing this incompatibility? >> >> Thanks, >> Ed >> >> -- >> Ed's Contact Information: >> Mobile Phone: 613-852-6410 >> Gmail: ed.shallow at gmail.com >> > >> VOIP Address: 107529 at sip.ca1.voip.ms >> > __> >> >> VOIP DID#: 613-458-5004 >> Skype ID: edward.shallow >> Home Phone: 613-482-2090 >> >> >> >> ______________________________**___________________ >> python-win32 mailing list >> python-win32 at python.org >> > >> http://mail.python.org/__**mailman/listinfo/python-win32 >> >> >> > >> >> >> >> >> >> >> -- >> Ed's Contact Information: >> Mobile Phone: 613-852-6410 >> Gmail: ed.shallow at gmail.com >> VOIP Address: 107529 at sip.ca1.voip.ms >> VOIP DID#: 613-458-5004 >> Skype ID: edward.shallow >> Home Phone: 613-482-2090 >> >> > > -- Ed's Contact Information: Mobile Phone: 613-852-6410 Gmail: ed.shallow at gmail.com VOIP Address: 107529 at sip.ca1.voip.ms VOIP DID#: 613-458-5004 Skype ID: edward.shallow Home Phone: 613-482-2090 -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sun May 20 09:04:08 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 20 May 2012 17:04:08 +1000 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 In-Reply-To: References: <4FB05AC7.6060000@gmail.com> <4FB0FFA0.6070109@skippinet.com.au> Message-ID: <4FB89768.1050704@gmail.com> On 20/05/2012 1:22 AM, EdShallow wrote: > Hi Mark, > > After much more testing here is some more to go on: > > Background again: > - I have a VisualBasic-generated ActiveX COM object called > capiCrypto.clsCrypto > - I call it like this > clsCrypto = win32com.client.Dispatch("capiCrypto.clsCrypto") > clsCrypto.InStringBuffer = newCert > clsCrypto.CRLFileName = self.Request.FqdnCRL > result = clsCrypto.CheckCertBufferAgainstCRLFile() > - it was generated on WinXP SP2 > - It can successfully be called from Python 2.3 win32-208 without problem > - As soon as I upgrade to Python 2.7 I get this stack trace without > touching the dll or its registration > 2012/05/19 10:18:12 INFO Traceback (most recent call last): > File "cherrypy\_cphttptools.pyo", line 271, in run > File "cherrypy\_cphttptools.pyo", line 502, in main > File "checkcertcrld.pyw", line 113, in crlHandler > File "CrlDispatch.pyo", line 121, in handle > File "CheckCertCrl.pyo", line 38, in execute > File "", line 3, in > CheckCertBufferAgainstCRLFile > com_error: (-2147417851, 'The server threw an exception.', None, None) > > Now here is some strange feedback . . . > - Knowing that everything was OK with Python 2.3, I isolated the above code > in its own HTTP process and py2exe'ed it thinking py2exe would preserve the > whole 2.3 call environment > - My thought was I would call the HTTP daemon which was packaged with 2.3 > and 208 from my 2.7 environment both in their own py2exe-created exe's one > in 2.7 the other in 2.3 > - So check this, the very first call to the dll in the 2.3 exe from the 2.7 > exe worked !!! Then all successive calls failed ???? So you have a Python 2.3 process that accepts incoming http connections and calls the crypto DLL, and it fails after making one call? So it should be possible to reproduce the problem in your 2.3 environment by simulating the incoming http connection and get the same behaviour? And are you sure this isn't the same thing you are seeing with 2.7 - one successful call then failure? (You didn't mention what version of pywin32 you were using with 2.7, which could be useful info.) I'm afraid it just sounds like a problem with the other DLL though. pywin32 still has a test case against a vb6 dll, so it doesn't seem a generic problem. I'd try asking them for some help diagnosing this... Cheers, Mark > - here is the log: > > 2012/05/19 08:53:28 INFO CheckCertCRL completed with TransactionStatus > ===> 1763 and TransactionStatusString ==> Certificate Revocation Check > failed Current time is NOT within the CRL validity period > > 2012/05/19 10:18:12 HTTP INFO 127.0.0.1 - POST /crlHandler HTTP/1.1 > 2012/05/19 10:18:12 INFO Traceback (most recent call last): > File "cherrypy\_cphttptools.pyo", line 271, in run > File "cherrypy\_cphttptools.pyo", line 502, in main > File "checkcertcrld.pyw", line 113, in crlHandler > File "CrlDispatch.pyo", line 121, in handle > File "CheckCertCrl.pyo", line 38, in execute > File "", line 3, in > CheckCertBufferAgainstCRLFile > com_error: (-2147417851, 'The server threw an exception.', None, None) > > - Note the first call which successfully checked the revocation status of a > certificate and returned a 1763 indicating a successful call to the COM dll > (although the cert check failed) > - Every subsequent time I called the dll it fails ??? > - Something happened in the environment after the first call and I have no > clue ??? > > Ed > > > On Mon, May 14, 2012 at 8:50 AM, Mark Hammond wrote: > >> [re-adding python-win32 - please keep replies on list] >> >> >> On 14/05/2012 10:39 PM, EdShallow wrote: >> >>> Hi Mark, >>> >>> Python 2.3 with pywin32-208 works. The error I receive reads >>> "Object through and exception at line 3". >>> >> >> How do you get that error? You say "my dll throws an exception >> immediately upon entry" - I can't reconcile that "with the error I >> receive". What does Python do when calling your failing DLL? (ie, do you >> get a traceback? If so, please include it completely. If not, what result >> does Python get? I'm still very unclear on the context of your problem. >> >> >> Un-registering and re-registering the dll does not help. >>> >> >> But that's just unregistering and re-registering your DLL right? >> >> >> The test was conducted on the same machine after uninstalling >>> Python and re-installing numerous combinations of Python 2.4, 2.5, 2.6, >>> 2.7 with associated pywin32-208 thry pywin32-214. >>> >>> If I uninstall the newer Python and re-install Python 2.3 and >>> pywin32-208 all is OK again. It is definitely environmental as opposed >>> to the code. >>> >> >> Well - it's *someone's* code :) To be clear, 2.3 + pywin32 209 fails? >> >> Mark >> >>> >>> Thanks, >>> Ed >>> >>> On Sun, May 13, 2012 at 9:07 PM, Mark Hammond >> >> wrote: >>> >>> You haven't given us enough information to help. What error do you >>> see? What is the most recent combination of Python and pywin32 that >>> works? >>> >>> Mark >>> >>> >>> On 12/05/2012 10:31 PM, EdShallow wrote: >>> >>> Hi Folks, >>> >>> I have an ActiveX COM dll generated by VisualBasic 6 in >>> WinXP. I >>> can call it and use it successfully with Python 2.3 and pywin32-208 >>> without problems. >>> >>> As soon as I upgrade either pywin32- or Python to anything >>> itself >>> to anything newer, my dll throws an exception immediately upon >>> entry. >>> >>> Can anyone point me in a general direction with respect to >>> addressing this incompatibility? >>> >>> Thanks, >>> Ed >>> >>> -- >>> Ed's Contact Information: >>> Mobile Phone: 613-852-6410 >>> Gmail: ed.shallow at gmail.com >>> > >>> VOIP Address: 107529 at sip.ca1.voip.ms >>> >> __> >>> >>> VOIP DID#: 613-458-5004 >>> Skype ID: edward.shallow >>> Home Phone: 613-482-2090 >>> >>> >>> >>> ______________________________**___________________ >>> python-win32 mailing list >>> python-win32 at python.org >>>> >>> http://mail.python.org/__**mailman/listinfo/python-win32 >>> >>> >>>> >>> >>> >>> >>> >>> >>> >>> -- >>> Ed's Contact Information: >>> Mobile Phone: 613-852-6410 >>> Gmail: ed.shallow at gmail.com >>> VOIP Address: 107529 at sip.ca1.voip.ms >>> VOIP DID#: 613-458-5004 >>> Skype ID: edward.shallow >>> Home Phone: 613-482-2090 >>> >>> >> >> > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From karra.etc at gmail.com Mon May 21 09:29:17 2012 From: karra.etc at gmail.com (Sriram Karra) Date: Mon, 21 May 2012 12:59:17 +0530 Subject: [python-win32] Creating a self-contained MSI or self-extracting installation executable Message-ID: I am working on a web application based on tornado and sqlalchemy that I want to distribute to Windows users so they can install and uninstall with zero pain and execute the program without needing to install anything else (including python or pywin32). After a bit of research it appears like there would be 2 distinct and perhaps totally unrelated parts of the problem: 1. Using something like py2exe or pyinstaller to create a standalone executable 2. Bundling it into a MSI or EXE - perhaps with the help of pywin32 Now my questions: First, is it correct that pywin32 has nothing to offer for Step 1? Second, is it correct that I could, theoretically use pywin32 fo Step 2? If yes, where should I start? Cheers -------------- next part -------------- An HTML attachment was scrubbed... URL: From nivthk at gmail.com Mon May 21 17:49:54 2012 From: nivthk at gmail.com (Nivth Ket) Date: Mon, 21 May 2012 09:49:54 -0600 Subject: [python-win32] Creating a self-contained MSI or self-extracting installation executable In-Reply-To: References: Message-ID: Shiram Karra, I am in no way experienced, but I do believe that pywin32 would not help with the first or second. In my opinion and experience, the easiest way to make the exe would be py2exe, and you should look to NSIS for making your installeer, as NSIS is fairly easy to use. Hoping I helped, Ninth. On Mon, May 21, 2012 at 1:29 AM, Sriram Karra wrote: > I am working on a web application based on tornado and sqlalchemy that I > want to distribute to Windows users so they can install and uninstall with > zero pain and execute the program without needing to install anything else > (including python or pywin32). After a bit of research it appears like > there would be 2 distinct and perhaps totally unrelated parts of the > problem: > > 1. Using something like py2exe or pyinstaller to create a standalone > executable > 2. Bundling it into a MSI or EXE - perhaps with the help of pywin32 > > Now my questions: > > First, is it correct that pywin32 has nothing to offer for Step 1? > > Second, is it correct that I could, theoretically use pywin32 fo Step 2? > If yes, where should I start? > > Cheers > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- Nivth Ket ^_^ Twitter Blog DeviantArt FurAffinity -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Tue May 22 02:02:15 2012 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 May 2012 20:02:15 -0400 Subject: [python-win32] DIR reports file timestamp and size, but os.path.getctime(), os.path.getsize() raise WindowsError [Error 5] Access is denied Message-ID: <1337644935.6074.140661078810709.631C0D98@webmail.messagingengine.com> Wondering if any of you have stumbled across the following behavior: I'm doing a recursive directory listing of my Windows folder and I can access the timestamps and file sizes of all files except the following 6 files: In the \windows\microsoft.net\framework\v2.0.50727\config folder: enterprisesec.config.cch.6824.14057640 security.config.cch.6824.14057640 In the \windows\\microsoft.net\framework64\v2.0.50727\config folder: \enterprisesec.config.cch.4412.14151427 enterprisesec.config.cch.6912.14056844 security.config.cch.4412.14151427 security.config.cch.6912.14056844 When I attempt to do any of the following on the above files, a WindowsError exception is raised with a value of "[Error 5] Access is denied: ...". os.path.getctime() os.path.getatime() os.path.getmtime() os.path.getsize() What's strange is that the DIR command from a cmd prompt returns timestamps and file sizes for the above files. Background; 64-bit Windows 7; 32-bit Python 2.7.2 Any ideas on how I can retrieve timestamps and file sizes like DIR without raising exceptions? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From planders at gmail.com Tue May 22 03:00:26 2012 From: planders at gmail.com (Preston Landers) Date: Mon, 21 May 2012 20:00:26 -0500 Subject: [python-win32] DIR reports file timestamp and size, but os.path.getctime(), os.path.getsize() raise WindowsError [Error 5] Access is denied In-Reply-To: <1337644935.6074.140661078810709.631C0D98@webmail.messagingengine.com> References: <1337644935.6074.140661078810709.631C0D98@webmail.messagingengine.com> Message-ID: I'm guessing Microsoft set some unusual ACLs on the files for security reasons. Have you looked at the advanced security options for these files in Windows Explorer? Have you tried running the script as Administrator? If you don't really care about the files you can skip them. If for some reason you absolutely have to retrieve that info, you could try tweaking the ACLs or maybe try launching a "dir" process and parse the output. -Preston From karra.etc at gmail.com Tue May 22 07:28:31 2012 From: karra.etc at gmail.com (Sriram Karra) Date: Tue, 22 May 2012 10:58:31 +0530 Subject: [python-win32] Creating a self-contained MSI or self-extracting installation executable In-Reply-To: References: Message-ID: Hm, ok. I think I will just go with py2exe and NSIS. Thanks Sriram On Mon, May 21, 2012 at 9:19 PM, Nivth Ket wrote: > Shiram Karra, I am in no way experienced, but I do believe that pywin32 > would not help with the first or second. In my opinion and experience, the > easiest way to make the exe would be py2exe, and you should look to NSIS > for making your installeer, as NSIS is fairly easy to use. > Hoping I helped, Ninth. > > On Mon, May 21, 2012 at 1:29 AM, Sriram Karra wrote: > >> I am working on a web application based on tornado and sqlalchemy that I >> want to distribute to Windows users so they can install and uninstall with >> zero pain and execute the program without needing to install anything else >> (including python or pywin32). After a bit of research it appears like >> there would be 2 distinct and perhaps totally unrelated parts of the >> problem: >> >> 1. Using something like py2exe or pyinstaller to create a standalone >> executable >> 2. Bundling it into a MSI or EXE - perhaps with the help of pywin32 >> >> Now my questions: >> >> First, is it correct that pywin32 has nothing to offer for Step 1? >> >> Second, is it correct that I could, theoretically use pywin32 fo Step 2? >> If yes, where should I start? >> >> Cheers >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> >> > > > -- > Nivth Ket ^_^ > Twitter > Blog > DeviantArt > FurAffinity > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed May 23 06:48:23 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 23 May 2012 14:48:23 +1000 Subject: [python-win32] DIR reports file timestamp and size, but os.path.getctime(), os.path.getsize() raise WindowsError [Error 5] Access is denied In-Reply-To: <1337644935.6074.140661078810709.631C0D98@webmail.messagingengine.com> References: <1337644935.6074.140661078810709.631C0D98@webmail.messagingengine.com> Message-ID: <4FBC6C17.4080600@gmail.com> On 22/05/2012 10:02 AM, python at bdurham.com wrote: > Wondering if any of you have stumbled across the following behavior: > I'm doing a recursive directory listing of my Windows folder and I can access > the timestamps and file sizes of all files except the following 6 files: > In the \windows\microsoft.net\framework\v2.0.50727\config folder: > enterprisesec.config.cch.6824.14057640 > security.config.cch.6824.14057640 > In the \windows\\microsoft.net\framework64\v2.0.50727\config folder: > \enterprisesec.config.cch.4412.14151427 > enterprisesec.config.cch.6912.14056844 > security.config.cch.4412.14151427 > security.config.cch.6912.14056844 > When I attempt to do any of the following on the above files, a WindowsError > exception is raised with a value of "[Error 5] Access is denied: ...". > os.path.getctime() > os.path.getatime() > os.path.getmtime() > os.path.getsize() > What's strange is that the DIR command from a cmd prompt returns timestamps and > file sizes for the above files. > Background; 64-bit Windows 7; 32-bit Python 2.7.2 > Any ideas on how I can retrieve timestamps and file sizes like DIR without > raising exceptions? You could try the win32api.FindFiles function. Mark > Thank you, > Malcolm > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From ed.shallow at gmail.com Thu May 24 03:02:58 2012 From: ed.shallow at gmail.com (EdShallow) Date: Wed, 23 May 2012 21:02:58 -0400 Subject: [python-win32] calling a dll after python 2.3 pywin32-208 In-Reply-To: <4FB89768.1050704@gmail.com> References: <4FB05AC7.6060000@gmail.com> <4FB0FFA0.6070109@skippinet.com.au> <4FB89768.1050704@gmail.com> Message-ID: Hi Marc, I finally found the bug. It had nothing to do with pywin32 (which is installed with ActiveState Python 2.7 BTW). It was an insidious change introduced with the new python-ldap-2.4.9 for 2.7 which expects CertificateRevocationList;binary as the attribute name for a CRL where CertificateRevocationList worked under the old python-ldap module. Before the correction this returned nothing which appeared as an object exception in the .dll. I thought it was the binding that was broken. Thanks for the time, Ed On Sun, May 20, 2012 at 3:04 AM, Mark Hammond wrote: > On 20/05/2012 1:22 AM, EdShallow wrote: > >> Hi Mark, >> >> After much more testing here is some more to go on: >> >> Background again: >> - I have a VisualBasic-generated ActiveX COM object called >> capiCrypto.clsCrypto >> - I call it like this >> clsCrypto = win32com.client.Dispatch("**capiCrypto.clsCrypto") >> clsCrypto.InStringBuffer = newCert >> clsCrypto.CRLFileName = self.Request.FqdnCRL >> result = clsCrypto.**CheckCertBufferAgainstCRLFile(**) >> - it was generated on WinXP SP2 >> - It can successfully be called from Python 2.3 win32-208 without problem >> - As soon as I upgrade to Python 2.7 I get this stack trace without >> touching the dll or its registration >> 2012/05/19 10:18:12 INFO Traceback (most recent call last): >> File "cherrypy\_cphttptools.pyo", line 271, in run >> File "cherrypy\_cphttptools.pyo", line 502, in main >> File "checkcertcrld.pyw", line 113, in crlHandler >> File "CrlDispatch.pyo", line 121, in handle >> File "CheckCertCrl.pyo", line 38, in execute >> File "", line 3, in >> CheckCertBufferAgainstCRLFile >> com_error: (-2147417851, 'The server threw an exception.', None, None) >> >> Now here is some strange feedback . . . >> - Knowing that everything was OK with Python 2.3, I isolated the above >> code >> in its own HTTP process and py2exe'ed it thinking py2exe would preserve >> the >> whole 2.3 call environment >> - My thought was I would call the HTTP daemon which was packaged with 2.3 >> and 208 from my 2.7 environment both in their own py2exe-created exe's one >> in 2.7 the other in 2.3 >> - So check this, the very first call to the dll in the 2.3 exe from the >> 2.7 >> exe worked !!! Then all successive calls failed ???? >> > > So you have a Python 2.3 process that accepts incoming http connections > and calls the crypto DLL, and it fails after making one call? So it should > be possible to reproduce the problem in your 2.3 environment by simulating > the incoming http connection and get the same behaviour? And are you sure > this isn't the same thing you are seeing with 2.7 - one successful call > then failure? (You didn't mention what version of pywin32 you were using > with 2.7, which could be useful info.) > > I'm afraid it just sounds like a problem with the other DLL though. > pywin32 still has a test case against a vb6 dll, so it doesn't seem a > generic problem. I'd try asking them for some help diagnosing this... > > Cheers, > > Mark > > - here is the log: >> >> 2012/05/19 08:53:28 INFO CheckCertCRL completed with TransactionStatus >> ===> 1763 and TransactionStatusString ==> Certificate Revocation Check >> failed Current time is NOT within the CRL validity period >> >> 2012/05/19 10:18:12 HTTP INFO 127.0.0.1 - POST /crlHandler HTTP/1.1 >> 2012/05/19 10:18:12 INFO Traceback (most recent call last): >> File "cherrypy\_cphttptools.pyo", line 271, in run >> File "cherrypy\_cphttptools.pyo", line 502, in main >> File "checkcertcrld.pyw", line 113, in crlHandler >> File "CrlDispatch.pyo", line 121, in handle >> File "CheckCertCrl.pyo", line 38, in execute >> File "", line 3, in >> CheckCertBufferAgainstCRLFile >> com_error: (-2147417851, 'The server threw an exception.', None, None) >> >> - Note the first call which successfully checked the revocation status of >> a >> certificate and returned a 1763 indicating a successful call to the COM >> dll >> (although the cert check failed) >> - Every subsequent time I called the dll it fails ??? >> - Something happened in the environment after the first call and I have no >> clue ??? >> >> Ed >> >> >> On Mon, May 14, 2012 at 8:50 AM, Mark Hammond >> **wrote: >> >> [re-adding python-win32 - please keep replies on list] >>> >>> >>> On 14/05/2012 10:39 PM, EdShallow wrote: >>> >>> Hi Mark, >>>> >>>> Python 2.3 with pywin32-208 works. The error I receive reads >>>> "Object through and exception at line 3". >>>> >>>> >>> How do you get that error? You say "my dll throws an exception >>> immediately upon entry" - I can't reconcile that "with the error I >>> receive". What does Python do when calling your failing DLL? (ie, do >>> you >>> get a traceback? If so, please include it completely. If not, what >>> result >>> does Python get? I'm still very unclear on the context of your problem. >>> >>> >>> Un-registering and re-registering the dll does not help. >>> >>>> >>>> >>> But that's just unregistering and re-registering your DLL right? >>> >>> >>> The test was conducted on the same machine after uninstalling >>> >>>> Python and re-installing numerous combinations of Python 2.4, 2.5, 2.6, >>>> 2.7 with associated pywin32-208 thry pywin32-214. >>>> >>>> If I uninstall the newer Python and re-install Python 2.3 and >>>> pywin32-208 all is OK again. It is definitely environmental as opposed >>>> to the code. >>>> >>>> >>> Well - it's *someone's* code :) To be clear, 2.3 + pywin32 209 fails? >>> >>> Mark >>> >>> >>>> Thanks, >>>> Ed >>>> >>>> On Sun, May 13, 2012 at 9:07 PM, Mark Hammond >>> >> >>>> wrote: >>>> >>>> You haven't given us enough information to help. What error do you >>>> see? What is the most recent combination of Python and pywin32 that >>>> works? >>>> >>>> Mark >>>> >>>> >>>> On 12/05/2012 10:31 PM, EdShallow wrote: >>>> >>>> Hi Folks, >>>> >>>> I have an ActiveX COM dll generated by VisualBasic 6 in >>>> WinXP. I >>>> can call it and use it successfully with Python 2.3 and >>>> pywin32-208 >>>> without problems. >>>> >>>> As soon as I upgrade either pywin32- or Python to anything >>>> itself >>>> to anything newer, my dll throws an exception immediately upon >>>> entry. >>>> >>>> Can anyone point me in a general direction with respect to >>>> addressing this incompatibility? >>>> >>>> Thanks, >>>> Ed >>>> >>>> -- >>>> Ed's Contact Information: >>>> Mobile Phone: 613-852-6410 >>>> Gmail: ed.shallow at gmail.com >>>> > >>>> VOIP Address: 107529 at sip.ca1.voip.ms >>>> >>> 107529 at sip.ca1.voip.ms >>>> __> >>>> >>>> >>>> VOIP DID#: 613-458-5004 >>>> Skype ID: edward.shallow >>>> Home Phone: 613-482-2090 >>>> >>>> >>>> >>>> ______________________________****___________________ >>>> python-win32 mailing list >>>> python-win32 at python.org >>> python-win32 at python.org> >>>> >>>>> >>>>> http://mail.python.org/__****mailman/listinfo/python-win32 >>>> <**http://mail.python.org/__**mailman/listinfo/python-win32 >>>> > >>>> >>>> >>>> <**http://mail.python.org/**mailman/listinfo/python-win32 >>>> > >>>> >>>> >>>>> >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> Ed's Contact Information: >>>> Mobile Phone: 613-852-6410 >>>> Gmail: ed.shallow at gmail.com >>>> VOIP Address: 107529 at sip.ca1.voip.ms >>> **> >>>> >>>> VOIP DID#: 613-458-5004 >>>> Skype ID: edward.shallow >>>> Home Phone: 613-482-2090 >>>> >>>> >>>> >>> >>> >> >> >> >> ______________________________**_________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/**mailman/listinfo/python-win32 >> >> > > -- Ed's Contact Information: Mobile Phone: 613-852-6410 Gmail: ed.shallow at gmail.com VOIP Address: 107529 at sip.ca1.voip.ms VOIP DID#: 613-458-5004 Skype ID: edward.shallow Home Phone: 613-482-2090 -------------- next part -------------- An HTML attachment was scrubbed... URL: From atrick at tri-tech.com Fri May 25 17:47:35 2012 From: atrick at tri-tech.com (Alan Trick) Date: Fri, 25 May 2012 08:47:35 -0700 Subject: [python-win32] adodbapi: using prepared statements Message-ID: I'm trying to use prepared statements with the adodbapi module, but it's not working. I'm using the Visual FoxPro OLE DB drivers, and I'm worried that this is just something that they can't handle. Here's some sample code: --- import adodbapi conn = adodbapi.connect('Provider=vfpoledb;Data Source=C:\ClinEsse\Data\Frost_7_12\medimax.dbc;Collating Sequence=machine') cur = conn.cursor() cur.execute("select * from chiro1 where prefix= 'LEG' ") print [`c` for c in cur.fetchall()] cur.execute("select * from chiro1 where prefix = ?", ['LEG']) print [`c` for c in cur.fetchall()] --- The first "execute" call returns a list of SQLrows, and works fine, but the second execute call (the prepared statement) raises the following exception. Traceback (most recent call last): File "test.py", line 9, in cur.execute("select * from chiro1 where prefix = ?", ['LEG']) File "C:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 1006, in execute self._buildADOparameterList(operation,parameters) File "C:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 963, in _buildADOparameterList p=getIndexedValue(self.cmd.Parameters,i) File "C:\Python27\lib\site-packages\adodbapi\adodbapi.py", line 77, in getIndexedValue return obj(index) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 186, in __call__ return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'ADODB.Parameters', u'Item cannot be found in the collection corresponding to the requested name or ordinal.', u'C:\\Windows\\HELP\\ADO270.CHM', 1240649, -2146825023), None) I've tried using different paramstyles but the all give the same result. From timr at probo.com Fri May 25 19:18:54 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 25 May 2012 10:18:54 -0700 Subject: [python-win32] adodbapi: using prepared statements In-Reply-To: References: Message-ID: <4FBFBEFE.6040502@probo.com> Alan Trick wrote: > I'm trying to use prepared statements with the adodbapi module, but > it's not working. I'm using the Visual FoxPro OLE DB drivers, and I'm > worried that this is just something that they can't handle. Well, there error is firing inside the adodbapi code, not in VFP, although it's possible that the OLE DB driver's parameter handling is interfering. The implication is that the OLE DB's provider has scanned the statement and decided the are no parameters to substitute. If you print conn.paramstyle, is it still qmark? Is there any change if you use a tuple instead of a list? That is: cur.execute("select * from chiro1 where prefix = ?", ('LEG',)) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From atrick at tri-tech.com Fri May 25 19:42:07 2012 From: atrick at tri-tech.com (Alan Trick) Date: Fri, 25 May 2012 10:42:07 -0700 Subject: [python-win32] adodbapi: using prepared statements In-Reply-To: References: <4FBFBEFE.6040502@probo.com> Message-ID: On Fri, May 25, 2012 at 10:18 AM, Tim Roberts wrote: > > If you print conn.paramstyle, is it still qmark? Yes, the default is qmark. > Is there any change if you use a tuple instead of a list? That is: > > cur.execute("select * from chiro1 where prefix = ?", ('LEG',)) I get an identital exception with a tuple. For what it's worth, the value of cur.query is different, but I don't know if that has any effect on anything. With a list, cur.query is set to "select * from chiro1 where prefix = ?,parameters=['LEG']", with a tuple it's "select * from chiro1 where prefix = ?,parameters=('LEG',)". P.S. Sorry time about the duplicate email Tim. I forgot that my email client was retarded and that I was on a mailing list ;-) From timr at probo.com Fri May 25 20:04:09 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 25 May 2012 11:04:09 -0700 Subject: [python-win32] adodbapi: using prepared statements In-Reply-To: References: <4FBFBEFE.6040502@probo.com> Message-ID: <4FBFC999.2080702@probo.com> Alan Trick wrote: > On Fri, May 25, 2012 at 10:18 AM, Tim Roberts wrote: >> Is there any change if you use a tuple instead of a list? That is: >> >> cur.execute("select * from chiro1 where prefix = ?", ('LEG',)) > I get an identital exception with a tuple. For what it's worth, the > value of cur.query is different, but I don't know if that has any > effect on anything. With a list, cur.query is set to "select * from > chiro1 where prefix = ?,parameters=['LEG']", with a tuple it's "select > * from chiro1 where prefix = ?,parameters=('LEG',)". I'd expect that. I am at a loss. The adodbapi code gives the OLE DB provider a first shot at processing the parameters. If that fails, then the Python code does the processing itself. My guess is that the OLE DB provider here is saying "it worked!", but isn't actually setting up the substitutions. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Fri May 25 23:53:28 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 25 May 2012 15:53:28 -0600 Subject: [python-win32] adodbapi: using prepared statements In-Reply-To: <4FBFC999.2080702@probo.com> References: <4FBFBEFE.6040502@probo.com> <4FBFC999.2080702@probo.com> Message-ID: On Fri, May 25, 2012 at 12:04 PM, Tim Roberts wrote: > Alan Trick wrote: > > On Fri, May 25, 2012 at 10:18 AM, Tim Roberts wrote: > >> Is there any change if you use a tuple instead of a list? That is: > >> > >> cur.execute("select * from chiro1 where prefix = ?", ('LEG',)) > > I get an identital exception with a tuple. For what it's worth, the > > value of cur.query is different, but I don't know if that has any > > effect on anything. With a list, cur.query is set to "select * from > > chiro1 where prefix = ?,parameters=['LEG']", with a tuple it's "select > > * from chiro1 where prefix = ?,parameters=('LEG',)". > > I'd expect that. > > I am at a loss. The adodbapi code gives the OLE DB provider a first shot > at processing the parameters. If that fails, then the Python code does > the processing itself. My guess is that the OLE DB provider here is > saying "it worked!", but isn't actually setting up the substitutions. > > -- > Tim Roberts, timr at probo.com > My guess is that Tim's guess is correct. ADO really doesn't do much to remove the differences between SQL engines, and the adodbapi code blindly hands stuff to it. If the FoxPro provider does not handle parameters, or expects some format other than qmark, you might see an error like this one. Try setting adodbapi.adodbapi.verbose = 4 and see if that sheds any light. Particularly look for the line that specifies 'error in COM Refresh(), so adodbapi is building a parameter list'. -- Vernon Cole -------------- next part -------------- An HTML attachment was scrubbed... URL: From atrick at tri-tech.com Sat May 26 00:06:25 2012 From: atrick at tri-tech.com (Alan Trick) Date: Fri, 25 May 2012 15:06:25 -0700 Subject: [python-win32] adodbapi: using prepared statements In-Reply-To: References: <4FBFBEFE.6040502@probo.com> <4FBFC999.2080702@probo.com> Message-ID: On Fri, May 25, 2012 at 2:53 PM, Vernon Cole wrote: > Try setting adodbapi.adodbapi.verbose = 4 and see if that sheds any light. > Particularly look for the line that specifies 'error in COM Refresh(), so > adodbapi is building a parameter list'. I already tried debugging it to get a gist of what it's doing and it does not hit that line, so I guess the provider must be pretending to support parametrized queries. Is there some way that I can force adodbapi to build the parameter list? From vernondcole at gmail.com Sat May 26 06:03:12 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 25 May 2012 22:03:12 -0600 Subject: [python-win32] adodbapi: using prepared statements In-Reply-To: References: <4FBFBEFE.6040502@probo.com> <4FBFC999.2080702@probo.com> Message-ID: {Sorry about the slow response... I had to go drive an ambulance...} You could try shortcutting the code in _buildADOparamteterList() to always execute the "except:" clause (around line 941). I suspect that the same error will persist -- but maybe not. (Aren't you glad you have source code?) -- Vernon On Fri, May 25, 2012 at 4:06 PM, Alan Trick wrote: > On Fri, May 25, 2012 at 2:53 PM, Vernon Cole > wrote: > > Try setting adodbapi.adodbapi.verbose = 4 and see if that sheds any > light. > > Particularly look for the line that specifies 'error in COM Refresh(), so > > adodbapi is building a parameter list'. > > I already tried debugging it to get a gist of what it's doing and it > does not hit that line, so I guess the provider must be pretending to > support parametrized queries. Is there some way that I can force > adodbapi to build the parameter list? > _______________________________________________ > 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 karbonforms at gmail.com Sat May 26 12:52:11 2012 From: karbonforms at gmail.com (Chris Ness) Date: Sat, 26 May 2012 11:52:11 +0100 Subject: [python-win32] Win7 explorer "include in library" submenu In-Reply-To: References: <4FBFBEFE.6040502@probo.com> <4FBFC999.2080702@probo.com> Message-ID: <4FC0B5DB.50308@gmail.com> I'm trying to replicate the win 7 explorer context menu on the fly. All works well apart from the "Include in Library" submenu, which shows one greyed out entry: "retrieving libraries...". Well it's not retrieving anything because the code to read the menus has returned! Here is my code that reads the menu entries... def __getMenuItems(hMenu, contextMenu): num_items = win32gui.GetMenuItemCount(hMenu) rval = [] for i in range(num_items): mi = EmptyMENUITEMINFO() win32gui.GetMenuItemInfo(hMenu, i, True, mi[0]) item = UnpackMENUITEMINFO(mi[0]) fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, text, hbmpItem = item if hSubMenu: hSubMenu = win32gui.GetSubMenu(hMenu, i) rval.append((__getMenuItems(hSubMenu, contextMenu), text)) else: rval.append((wID, text)) return rval I have no idea what to do and google is no help. Do I need to initiate something? Wait for something? Any help much appreciated! chris From damienmoloney at gmail.com Sun May 27 12:54:30 2012 From: damienmoloney at gmail.com (damien moloney) Date: Sun, 27 May 2012 20:54:30 +1000 Subject: [python-win32] Retrieve file property values Message-ID: Hi, Have been unable to retrieve the windows file properties/attributes under "Subject", and "Description". for .msi files on a Win XP c using win32api. Have been able to get version type info, but unable to get much more. I came across the following "from win32com import storagecon # constants related to storage functions." which looked promising but fell over as the .msi files I was looking at are not "storage files". Any ides on where next. Thanks Damien. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hossain.iqbal at gmail.com Sun May 27 23:18:22 2012 From: hossain.iqbal at gmail.com (Riz Hossain) Date: Sun, 27 May 2012 21:18:22 +0000 Subject: [python-win32] WPF drag drop UI automation Message-ID: <1897245624-1338153498-cardhu_decombobulator_blackberry.rim.net-487037392-@b14.c4.bise6.blackberry> Hello, If anyone could kindly direct me in the right direction for WPF drag and drop control using python, it would be greatly appreciated. I need to be able to drag drop elements from one object to another within the application. My automation framework is written all in python, so I would really love to achieve this with python. Advanced thanks for any suggestions and help. Thanks, Riz Sent from my BlackBerry Torch From mail at timgolden.me.uk Mon May 28 16:19:14 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 28 May 2012 15:19:14 +0100 Subject: [python-win32] Retrieve file property values In-Reply-To: References: Message-ID: <4FC38962.5070002@timgolden.me.uk> On 27/05/2012 11:54, damien moloney wrote: > Hi, > > Have been unable to retrieve the windows file properties/attributes > under "Subject", and "Description". for .msi files on a Win XP c using > win32api. Have been able to get version type info, > but unable to get much more. I came across the following "fromwin32com > importstoragecon # constants related to storage functions." which looked > promising but fell over as the .msi files I was looking at are not > "storage files". Any ides on where next. This is a bit more complicated than you might like. I have a half-hearted example here: http://timgolden.me.uk/python/win32_how_do_i/get-document-summary-info.html and the in-dev version of my winshell module includes some more general-purpose code which you might at least want to look at even though it's not 100% at the moment: https://github.com/tjguk/winshell Part of the difficulty is that Windows has switched between two approaches to this area which doesn't help when trying to get examples. TJG From timr at probo.com Tue May 29 21:10:04 2012 From: timr at probo.com (Tim Roberts) Date: Tue, 29 May 2012 12:10:04 -0700 Subject: [python-win32] WPF drag drop UI automation In-Reply-To: <1897245624-1338153498-cardhu_decombobulator_blackberry.rim.net-487037392-@b14.c4.bise6.blackberry> References: <1897245624-1338153498-cardhu_decombobulator_blackberry.rim.net-487037392-@b14.c4.bise6.blackberry> Message-ID: <4FC51F0C.3030306@probo.com> Riz Hossain wrote: > If anyone could kindly direct me in the right direction for WPF drag and drop control using python, it would be greatly appreciated. > > I need to be able to drag drop elements from one object to another within the application. My automation framework is written all in python, so I would really love to achieve this with python. Are you using IronPython? WPF is strictly a .NET technology. You can't play in that world from C Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From etaoinbe at yahoo.com Thu May 31 10:34:29 2012 From: etaoinbe at yahoo.com (jo) Date: Thu, 31 May 2012 01:34:29 -0700 (PDT) Subject: [python-win32] how to switch keyboards in windows with win32api ? Message-ID: <1338453269.66225.YahooMailNeo@web39406.mail.mud.yahoo.com> Hi On windows 7 I have not managed to switch keyboard to dutch netherlands with below script. It does switch to US keyboard though. What am I doing wrong...? I have been experimenting with different parameters and so on. msdn also mentions ActivateKeyboardLayout but it does not appear in my win32api. import sys sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' ?python setkeyboard.py win32api.GetLastError()=0 GetKeyboardLayout : 68355091 4130413 win32api.GetLastError()=0 67699721 4090409 win32api.GetLastError()=0 GetKeyboardLayout : 67699721 4090409 win32api.GetLastError()=0 67699721 4090409 GetKeyboardLayout :? 67699721 4090409 Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation.? All rights reserved. ?type setkeyboard.py import win32api,win32con,os # kl=win32api.LoadKeyboardLayout('135464979',19|win32con.KLF_SETFORPROCESS|win32con.KLF_REORDER) oldkl= win32api.GetKeyboardLayout() print "win32api.GetLastError()=%s " % win32api.GetLastError() print "GetKeyboardLayout : %s %x " % (oldkl,oldkl) #### kl=win32api.LoadKeyboardLayout('8130813',19|win32con.KLF_SETFORPROCESS|win32con.KLF_REORDER) print "win32api.GetLastError()=%s " % win32api.GetLastError() print "%s %x " % (kl,kl) curkl= win32api.GetKeyboardLayout() print "win32api.GetLastError()=%s " % win32api.GetLastError() print "GetKeyboardLayout : %s %x " % (curkl,curkl) ### kl=win32api.LoadKeyboardLayout('135464979',19|win32con.KLF_SETFORPROCESS|win32con.KLF_REORDER) print "win32api.GetLastError()=%s " % win32api.GetLastError() print "%s %x " % (kl,kl) curkl= win32api.GetKeyboardLayout() print "GetKeyboardLayout :? %s %x " % (curkl,curkl) os.system("cmd") Kind Regards, joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin.horn at gmail.com Thu May 31 15:40:42 2012 From: kevin.horn at gmail.com (Kevin Horn) Date: Thu, 31 May 2012 08:40:42 -0500 Subject: [python-win32] Importing tempfile (or random) results in disaster... Message-ID: I'm setting up a new machine (Win7) and one of the first things I thought I'd do is install Python, distribute, pip, virtualenv, etc. However, I can't seem to get that far. When trying to install distribute (using distribute_setup.py), I get the following traceback: Traceback (most recent call last): File "distribute_setup.py", line 20, in import tempfile File "C:\Python27\lib\tempfile.py", line 34, in from random import Random as _Random File "C:\Python27\lib\random.py", line 881, in _inst = Random() File "C:\Python27\lib\random.py", line 97, in __init__ self.seed(x) File "C:\Python27\lib\random.py", line 111, in seed a = long(_hexlify(_urandom(16)), 16) WindowsError: [Error -2146893818] Invalid Signature "Huh," I thought. "That's weird". A little googling turned up this bug: http://bugs.python.org/issue13524 Which has the same traceback, but purports to have something to do with not passing the right environment to the subprocess module (and is marked as "Wontfix"). But this doesn't seem to me to be the problem, as I'm not using the subprocess module. In fact, here is the minimal reproducible example on my machine: tfile.py: import tempfile That's it. Just "import tempfile" and Python comes to a screeching halt. In fact, "import random" does this as well, and either one will also cause the traceback from within the interactive interpreter. What's going on here? Is this a Win7 thing? I have 2.7.3 working on XP and Vista without a problem. Any pointers? Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu May 31 18:09:24 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 31 May 2012 17:09:24 +0100 Subject: [python-win32] Importing tempfile (or random) results in disaster... In-Reply-To: References: Message-ID: <4FC797B4.80606@timgolden.me.uk> On 31/05/2012 14:40, Kevin Horn wrote: > I'm setting up a new machine (Win7) and one of the first things I > thought I'd do is install Python, distribute, pip, virtualenv, etc. > > However, I can't seem to get that far. > > When trying to install distribute (using distribute_setup.py), I get the > following traceback: > > Traceback (most recent call last): > File "distribute_setup.py", line 20, in > import tempfile > File "C:\Python27\lib\tempfile.py", line 34, in > from random import Random as _Random > File "C:\Python27\lib\random.py", line 881, in > _inst = Random() > File "C:\Python27\lib\random.py", line 97, in __init__ > self.seed(x) > File "C:\Python27\lib\random.py", line 111, in seed > a = long(_hexlify(_urandom(16)), 16) > WindowsError: [Error -2146893818] Invalid Signature > > "Huh," I thought. "That's weird". > > A little googling turned up this bug: > > http://bugs.python.org/issue13524 > > Which has the same traceback, but purports to have something to do with > not passing the right environment to the subprocess module (and is > marked as "Wontfix"). > > But this doesn't seem to me to be the problem, as I'm not using the > subprocess module. In fact, here is the minimal reproducible example on > my machine: > > tfile.py: > import tempfile > > > > That's it. Just "import tempfile" and Python comes to a screeching > halt. In fact, "import random" does this as well, and either one will > also cause the traceback from within the interactive interpreter. > > What's going on here? Is this a Win7 thing? I have 2.7.3 working on XP > and Vista without a problem. Are you inside a virtualenv? There was a venv bug recently which manifested itself in a similar way. Hang on... Have a look around here (not sure exactly which part of the thread to pull at) and see if anything rings bells. http://mail.python.org/pipermail/python-dev/2012-March/118233.html TJG From kevin.horn at gmail.com Thu May 31 18:26:07 2012 From: kevin.horn at gmail.com (Kevin Horn) Date: Thu, 31 May 2012 11:26:07 -0500 Subject: [python-win32] Fwd: Importing tempfile (or random) results in disaster... In-Reply-To: References: <4FC797B4.80606@timgolden.me.uk> Message-ID: On Thu, May 31, 2012 at 11:09 AM, Tim Golden wrote: > On 31/05/2012 14:40, Kevin Horn wrote: > > I'm setting up a new machine (Win7) and one of the first things I > > thought I'd do is install Python, distribute, pip, virtualenv, etc. > > > > However, I can't seem to get that far. > > > > When trying to install distribute (using distribute_setup.py), I get the > > following traceback: > > > > Traceback (most recent call last): > > File "distribute_setup.py", line 20, in > > import tempfile > > File "C:\Python27\lib\tempfile.py", line 34, in > > from random import Random as _Random > > File "C:\Python27\lib\random.py", line 881, in > > _inst = Random() > > File "C:\Python27\lib\random.py", line 97, in __init__ > > self.seed(x) > > File "C:\Python27\lib\random.py", line 111, in seed > > a = long(_hexlify(_urandom(16)), 16) > > WindowsError: [Error -2146893818] Invalid Signature > > > > "Huh," I thought. "That's weird". > > > > A little googling turned up this bug: > > > > http://bugs.python.org/issue13524 > > > > Which has the same traceback, but purports to have something to do with > > not passing the right environment to the subprocess module (and is > > marked as "Wontfix"). > > > > But this doesn't seem to me to be the problem, as I'm not using the > > subprocess module. In fact, here is the minimal reproducible example on > > my machine: > > > > tfile.py: > > import tempfile > > > > > > > > That's it. Just "import tempfile" and Python comes to a screeching > > halt. In fact, "import random" does this as well, and either one will > > also cause the traceback from within the interactive interpreter. > > > > What's going on here? Is this a Win7 thing? I have 2.7.3 working on XP > > and Vista without a problem. > > Are you inside a virtualenv? There was a venv bug recently > which manifested itself in a similar way. Hang on... > > Have a look around here (not sure exactly which part of the > thread to pull at) and see if anything rings bells. > > http://mail.python.org/pipermail/python-dev/2012-March/118233.html > > TJG > > OK, so I have no idea what caused this, but apparently rebooting my machine fixed it. I guess that should have been my first instinct (thanks, Windows!). I have no idea why a reboot would fix this though. Thanks for the reply though, Tim. Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: