From david at bigredmedia.tv Mon Jul 12 18:46:00 2010 From: david at bigredmedia.tv (David Briant) Date: Mon, 12 Jul 2010 17:46:00 +0100 Subject: [python-win32] comtypes-0.6.1 released Message-ID: <2FFEC162ECCD49DCB065BB06D0AAAF1F@Galadriel> Hi I'm using comtypes. And want to convert double arrays between numpy arrays and OLESafeArrays. I notice a changelog item 0.6.1 that says this has been done. Has this been removed? Thx David -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at bigredmedia.tv Mon Jul 12 19:43:22 2010 From: david at bigredmedia.tv (David Briant) Date: Mon, 12 Jul 2010 18:43:22 +0100 Subject: [python-win32] Solved - Re: comtypes-0.6.1 released Message-ID: <7AF2DA3557FD4B2D8F55ECF9091B3F0B@Galadriel> Hi I think I've answered my own question... I needed to add a constructor option in the VARIANT bit to create from a numpy array... I just need to add the conversion to get a numpy array from a olesafe array if numpy is loaded... Thx david _____________________________________________ From: David Briant [mailto:david at bigredmedia.tv] Sent: 12 July 2010 17:46 To: 'python-win32 at python.org' Subject: Re: [python-win32] comtypes-0.6.1 released Hi I'm using comtypes. And want to convert double arrays between numpy arrays and OLESafeArrays. I notice a changelog item 0.6.1 that says this has been done. Has this been removed? Thx David -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 27729 bytes Desc: not available URL: From petr at dlabal.cz Tue Jul 13 10:23:54 2010 From: petr at dlabal.cz (Petr Dlabal) Date: Tue, 13 Jul 2010 10:23:54 +0200 Subject: [python-win32] EOFError in gencache.py In-Reply-To: <17632efd0907211128kc923d22sa1f412fe366774ab@mail.gmail.com> References: <17632efd0907211128kc923d22sa1f412fe366774ab@mail.gmail.com> Message-ID: Hi, I have a similar problem as described bellow - launching multiple instances of my application causes rewriting dicts.dat file in gen_py cache, sometimes when two processes running at the same time it leads to errors, because of locked dicts.dat. Is there some way to prevent this file to rewrite at every EnsureDispatch()? I tried to set it readonly -> : [Errno 13] Permission denied: 'C:\\Python26\\lib\\site-packages\\win32com\\gen_py\\dicts.dat' args = (13, 'Permission denied') errno = 13 filename = r'C:\Python26\lib\site-packages\win32com\gen_py\dicts.dat' message = '' strerror = 'Permission denied' (I am launching the script from cgi environment) Thanks for any help Peter On Tue, Jul 21, 2009 at 8:28 PM, Paul Hudson wrote: > Hi, > > I am having a similar problem when launching multiple instances of an > Application that allows Python scripting via COM.? (Yes, I am launching > these instances at the same time.) > > The error I get is: > > ? File "C:\Python26\Lib\site-packages\win32com\client\makepy.py", line 288, > in GenerateFromTypeLibSpec > ??? os.rename(outputName + ".temp", outputName) > : [Error 32] The process cannot access the > file because it is being used by another process > pythoncom error: Unexpected exception in gateway method 'AddTypeLib' > > As stated below, I understand the gen_py folder is not thread-safe.? The > behavior I am seeing suggests many of the __init__.py files are being > rewritten every time an instance of my App initiates Python.? Is this normal > win32com.client implementation?? If I am using the same App day after day, > do the gen_py folders and files need rewritten constantly?? Is there a way > to tuck away the gen_py files for this App into a more permanent location? > > > Thanks, > Paul > >> >> ---------------Original Message---------------------- >> >> On 5/02/2009 9:40 AM, Zdenek Mejzlik wrote: >> > File "c:\python25\lib\site-packages\win32com\client\gencache.py", line >> > 109, in _LoadDicts >> > version = p.load() >> > EOFError >> >> >> This is an error loading 'dicts.dat' from the win32com\gen_py directory. >> The management of this file is very crude and doesn't protect against >> threads or processes stomping on other. >> >> Does you app create COM objects on different threads, or are there >> >> multiple instances of your app starting at the same time? If so, we >> might like to instrument the code to see if this indeed the problem. >> >> > If I uninstall both pywin and Python and install them again the problem >> >> > disappears. But it is only temporary >> > solution the problem returns back after several days. Please, help me to >> > find the definitive solution. >> >> A quicker workaround should be to remove dicts.dat, or indeed, the >> >> contents of the entire gen_py directory (but don't remove the directory >> itself, or makepy will assume it can't write to win32com and use a >> gen_py under %TEMP%.) >> >> Cheers, >> >> Mark > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From vittorio.zuccala at gmail.com Tue Jul 13 15:50:15 2010 From: vittorio.zuccala at gmail.com (Vittorio Zuccala') Date: Tue, 13 Jul 2010 15:50:15 +0200 Subject: [python-win32] GetDiskFreeSpaceEx Message-ID: Hi all, i'm new in this mail-list and in python's programming. Sorry for my bad english :-) I'm searching information about getting free disk space on win32 systems... I found example about win32 programming in python in Tim's site at this link http://timgolden.me.uk/python/win32_how_do_i/lock_my_workstation.html and information about Free Disk Space at this link: http://msdn.microsoft.com/en-us/library/aa364937%28VS.85%29.aspx So... I tried to make 1+1 with this code but it doesn't work :-( import ctypes ctypes.windll.kernel32.GetDiskFreeSpaceEx() May you help me to understand? PS: i wrote code into linux. I'm just new in win32 system programming. Many thanks, Vittorio -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 13 16:10:42 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 13 Jul 2010 15:10:42 +0100 Subject: [python-win32] GetDiskFreeSpaceEx In-Reply-To: References: Message-ID: <4C3C73E2.4040100@timgolden.me.uk> On 13/07/2010 14:50, Vittorio Zuccala' wrote: > Hi all, > i'm new in this mail-list and in python's programming. Welcome to Python and to this group. > I'm searching information about getting free disk space on win32 systems... > > I found example about win32 programming in python in Tim's site at this link > http://timgolden.me.uk/python/win32_how_do_i/lock_my_workstation.html and > information about Free Disk Space at this link: > http://msdn.microsoft.com/en-us/library/aa364937%28VS.85%29.aspx If you haven't already, get hold of the pywin32 extensions to Python: https://sourceforge.net/projects/pywin32/ They contain a *lot* of the Win32 API that you'll need. Including the one you're after: http://timgolden.me.uk/pywin32-docs/win32api__GetDiskFreeSpaceEx_meth.html So if you had the modules installed, the code would look something like this: import win32api n_free_user, n_total, n_free = win32api.GetDiskFreeSpaceEx ("c:/") print ("Total disk size: %d bytes" % n_total) TJG From mail at timgolden.me.uk Tue Jul 13 16:41:10 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 13 Jul 2010 15:41:10 +0100 Subject: [python-win32] GetDiskFreeSpaceEx In-Reply-To: References: <4C3C73E2.4040100@timgolden.me.uk> Message-ID: <4C3C7B06.4020204@timgolden.me.uk> [cc-ing back to the list so other helpers and future Seekers of the Truth can see what happened next...] On 13/07/2010 15:27, Vittorio Zuccala' wrote: > 2010/7/13 Tim Golden > >> If you haven't already, get hold of the pywin32 extensions to Python: >> >> https://sourceforge.net/projects/pywin32/ >> >> They contain a *lot* of the Win32 API that you'll need. Including the one >> you're after: >> > > > Ok, i've downloaded and installed it. > Wonderful! > This page is very useful > http://timgolden.me.uk/pywin32-docs/win32_modules.html I can only take a small amount of credit there. All the work producing the pywin32 package was done by Mark Hammond, Roger Upole and others. My small contribution here is to take the .chm it ships with and to unpack it into individual HTML pages. Glad it's helpful. > So.. let me understand better. > ctypes is a module which let the programmer to interface with system > libraries. > win32api is a sort of extension of ctypes for win32 systems. > Are these two sentences correct? > The first certainly is. The second... not quite. Python has a C API: http://docs.python.org/c-api/ which can be used to wrap external systems / libraries etc. and expose them as Python objects. This been in existence for as long as Python itself, and is used by pywin32 and many other projects to offer Python the ability to interface with toolkits, libraries and so on. ctypes was a later addition, courtesy of the ingenious Thomas Heller. It lets you interface with shared libraries directly from Python without having to write C code. This has several advantages: (1) you don't have to write anything externally and link it in; (2) you're insulated to some extent from compiler / type library incompatibilities; (3) it's *really* easy to use and drops things straight into Python. And several disadvantages: (1) you sometimes have to work quite hard to translate C-level examples into ctypes Python; (2) you can crash Python hard -- something it's very difficult to do with the language alone. TJG From stormy at stormweyr.dk Tue Jul 13 16:32:53 2010 From: stormy at stormweyr.dk (Stormy) Date: Tue, 13 Jul 2010 15:32:53 +0100 Subject: [python-win32] GetDiskFreeSpaceEx In-Reply-To: References: Message-ID: GetDiskFreeSpaceEx() has two names (as does most windows functions that use strings), the Ansi version and the Unicode version, and you need to use the real name for the function you wish to use, in this case it is GetDiskFreeSpaceExA and GetDiskFreeSpaceExW. As for calling this function: http://docs.python.org/library/ctypes.html#passing-pointers-or-passing-parameters-by-reference from ctypes import c_ulong, byref, windll freeBytesAvailable = c_ulong() totalNumberOfBytes = c_ulong() totalNumberOfFreeBytes = c_ulong() # Ansi version: windll.kernel32.GetDiskFreeSpaceExA('c:\\', byref(freeBytesAvailable), byref(totalNumberOfBytes), byref(totalNumberOfFreeBytes)) # Unicode version: windll.kernel32.GetDiskFreeSpaceExW(u'c:\\', byref(freeBytesAvailable), byref(totalNumberOfBytes), byref(totalNumberOfFreeBytes)) print totalNumberOfFreeBytes.value The only difference in parameters is the type of string passed. On Tue, Jul 13, 2010 at 2:50 PM, Vittorio Zuccala' wrote: > Hi all, > i'm new in this mail-list and in python's programming. > Sorry for my bad english :-) > > I'm searching information about getting free disk space on win32 systems... > > I found example about win32 programming in python in Tim's site at this link > http://timgolden.me.uk/python/win32_how_do_i/lock_my_workstation.html and > information about Free Disk Space at this link: > http://msdn.microsoft.com/en-us/library/aa364937%28VS.85%29.aspx > > So... I tried to make 1+1 with this code but it doesn't work :-( > > import ctypes > ctypes.windll.kernel32.GetDiskFreeSpaceEx() > > May you help me to understand? > PS: i wrote code into linux. I'm just new in win32 system programming. > > Many thanks, > Vittorio > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From greg.antal at ata-e.com Wed Jul 14 18:37:30 2010 From: greg.antal at ata-e.com (Greg Antal) Date: Wed, 14 Jul 2010 09:37:30 -0700 Subject: [python-win32] EOFError in gencache.py In-Reply-To: References: <17632efd0907211128kc923d22sa1f412fe366774ab@mail.gmail.com> Message-ID: <4C3DE7CA.2020103@ata-e.com> An HTML attachment was scrubbed... URL: From justmike2000 at gmail.com Mon Jul 19 14:50:40 2010 From: justmike2000 at gmail.com (Michael Mileusnich) Date: Mon, 19 Jul 2010 07:50:40 -0500 Subject: [python-win32] pywin32 services Message-ID: Hello, I am trying to run my app as a windows service however I run into the following problem: Traceback (most recent call last): File "hqmonitor.py", line 220, in File "win32serviceutil.pyc", line 528, in HandleCommandLine File "win32serviceutil.pyc", line 468, in GetServiceClassString IndexError: list index out of range Can anybody shed some light on this? Python 2.6 Windows XP SP2 Thanks Mike Miles -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Mon Jul 19 17:24:32 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 19 Jul 2010 09:24:32 -0600 Subject: [python-win32] pywin32 services In-Reply-To: References: Message-ID: Well, you get that specific error from something like: >>> list1 = ['this is a','list'] >>> anError = list1[2] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range What does the code look like at hqmonitor.py line 220? -- VC On Mon, Jul 19, 2010 at 6:50 AM, Michael Mileusnich wrote: > Hello, > > I am trying to run my app as a windows service however I run > into the following problem: > > Traceback (most recent call last): > File "hqmonitor.py", line 220, in > File "win32serviceutil.pyc", line 528, in HandleCommandLine > File "win32serviceutil.pyc", line 468, in GetServiceClassString > IndexError: list index out of range > > Can anybody shed some light on this? > > Python 2.6 Windows XP SP2 > > Thanks > Mike Miles > _______________________________________________ > 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 Marc-Andre.Belzile at autodesk.com Mon Jul 19 18:01:42 2010 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Mon, 19 Jul 2010 09:01:42 -0700 Subject: [python-win32] sys.path and PyWin32 scripting engine Message-ID: Hi, Is the value of sys.path private for each new scripting engine I create ? Or is it global value ? According to my test results, any new paths added to sys.path from a specific engine seems to be available to others. Is it the expected behavior ? thanks -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jul 19 21:36:49 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 19 Jul 2010 12:36:49 -0700 Subject: [python-win32] sys.path and PyWin32 scripting engine In-Reply-To: References: Message-ID: <4C44A951.7070406@probo.com> Marc-Andre Belzile wrote: > > > > Is the value of sys.path private for each new scripting engine I > create ? Or is it global value ? > > > > According to my test results, any new paths added to sys.path from a > specific engine seems to be available to others. Is it the expected > behavior ? > I'm not sure what you mean by "new scripting engine". Modules are shared between all interpreters in a single process, but when you call Py_NewInterpreter, it is supposed to get its own private copy of sys.modules and sys.path (among several others). Can you be more specific? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From justmike2000 at gmail.com Mon Jul 19 14:39:11 2010 From: justmike2000 at gmail.com (Michael Mileusnich) Date: Mon, 19 Jul 2010 07:39:11 -0500 Subject: [python-win32] pywin32 services Message-ID: Hello, I am trying to run my app as a windows service however I run into the following problem: Traceback (most recent call last): File "hqmonitor.py", line 220, in File "win32serviceutil.pyc", line 528, in HandleCommandLine File "win32serviceutil.pyc", line 468, in GetServiceClassString IndexError: list index out of range Can anybody shed some light on this? Python 2.6 Windows XP SP2 Thanks Mike Miles -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jul 20 00:41:24 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 19 Jul 2010 15:41:24 -0700 Subject: [python-win32] pywin32 services In-Reply-To: References: Message-ID: <4C44D494.1070506@probo.com> Michael Mileusnich wrote: > > I am trying to run my app as a windows service however I run > into the following problem: > > Traceback (most recent call last): > File "hqmonitor.py", line 220, in > File "win32serviceutil.pyc", line 528, in HandleCommandLine > File "win32serviceutil.pyc", line 468, in GetServiceClassString > IndexError: list index out of range It's trying to find the full path name of the script, but the call to fetch the directory entry seems to have failed. Is it possible your script lives on a network share? Services run in a special user account that doesn't know anything about your network shares. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From roberto.c.aguilar at gmail.com Tue Jul 20 00:53:33 2010 From: roberto.c.aguilar at gmail.com (Roberto Aguilar) Date: Mon, 19 Jul 2010 15:53:33 -0700 Subject: [python-win32] pywin32 services In-Reply-To: References: Message-ID: <71569E7C-3C74-4BC9-89D0-94367ADB9E34@gmail.com> On Jul 19, 2010, at 5:39 AM, Michael Mileusnich wrote: > Hello, > > I am trying to run my app as a windows service however I run > into the following problem: > > Traceback (most recent call last): > File "hqmonitor.py", line 220, in > File "win32serviceutil.pyc", line 528, in HandleCommandLine > File "win32serviceutil.pyc", line 468, in GetServiceClassString > IndexError: list index out of range > > Can anybody shed some light on this? > > Python 2.6 Windows XP SP2 I'm not familiar with your particular error, but I am successfully running a python service under Windows and can show you what I did to get it working. I found the following snippets in similar form on the internets somewhere (unfortunately, I don't know from where). First, make sure you have pywin32. Since you're asking on this list, I presume you already have it. Next, there's the instart() function, which installs and starts the service [1]. Then, there's your particular service. You can extend the base class below [2] and define the start() and stop() methods as you need them. For example, I have a python app that I run using Popen. My subclass looks something like: class MyService(Service): _svc_name = 'myservice' _svc_display_name_ = 'My Python Service' [...] def start(self): self.ric = Popen(self.COMMAND, env=os.environ) def stop(self): self.ric.terminate() Finally, the script that installs and starts the service for the first time: #!/usr/bin/env python import sys from yourmodule import MyService, instart instart(MyService) After you run that the first time, you can start stop the service from the management console or using the net command (using the name defined in _svc_name): net stop myservice net start myservice Hope this helps, -Roberto. [1] the instart function: import pywintypes from os.path import splitext, abspath from sys import modules import win32api import win32service import win32serviceutil def instart(cls, stay_alive=True): """ Install and Start (auto) a Service cls : the class (derived from Service) that implement the Service name : Service name display_name : the name displayed in the service manager stay_alive : Service will stop on logout if False """ try: module_path = modules[cls.__module__].__file__ except AttributeError: # maybe py2exe went by from sys import executable module_path = executable module_file = splitext(abspath(module_path))[0] cls._svc_reg_class_ = '%s.%s' % (module_file, cls.__name__) if stay_alive: win32api.SetConsoleCtrlHandler(lambda x: True, True) try: win32serviceutil.InstallService( cls._svc_reg_class_, cls._svc_name_, cls._svc_display_name_, startType = win32service.SERVICE_AUTO_START ) except pywintypes.error, msg: # error 1073 is for 'CreateService', 'The specified service already # exists.' if we don't get this error, raise it if msg[0] != 1073: raise try: win32serviceutil.StartService(cls._svc_name_) except Exception, x: print x.__class__ print str(x) [2] The base service class import win32api import win32event import win32service import win32serviceutil class Service(win32serviceutil.ServiceFramework): _svc_name_ = '_unNamed' _svc_display_name_ = 'Python Service Template' def __init__(self, *args): win32serviceutil.ServiceFramework.__init__(self, *args) self.log('init') self.stop_event = win32event.CreateEvent(None, 0, 0, None) def log(self, msg): import servicemanager servicemanager.LogInfoMsg(str(msg)) def sleep(self, sec): win32api.Sleep(sec*1000, True) def SvcDoRun(self): self.ReportServiceStatus(win32service.SERVICE_START_PENDING) try: self.ReportServiceStatus(win32service.SERVICE_RUNNING) #self.log('start') self.start() #self.log('wait') win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE) #self.log('done') except Exception, x: self.log('Exception : %s' % x) self.SvcStop() def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) #self.log('stopping') self.stop() #self.log('stopped') win32event.SetEvent(self.stop_event) self.ReportServiceStatus(win32service.SERVICE_STOPPED) # to be overridden def start(self): pass # to be overridden def stop(self): pass From timr at probo.com Tue Jul 20 01:08:50 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 19 Jul 2010 16:08:50 -0700 Subject: [python-win32] pywin32 services In-Reply-To: References: <4C44D494.1070506@probo.com> Message-ID: <4C44DB02.1030404@probo.com> Michael Mileusnich wrote: > This is all local to my C drive. I opened up win32serviceutil and > printed out fname and it is the directory where my app is running out > of which is on C. It is longer than 8 characters I'm not sure how > FindFiles works. FindFiles returns a tuple of interesting things about the data. The 8th thing in that tuple is the official file name. fname should not be a directory. "fname" should be the full path to the executable. "path" should be the path part of that -- everything up to the last backslash. The join reads the directory to find the full file name, and tacks that on to the path. 99.99% of the time, "fname" should end up the same coming out as it was going in. It would be nice to know whether the "index" it's complaining about is the [0] (meaning FindFiles found no matches) or the [8] (meaning FindFiles returned something unexpected). Perhaps you should add print win32api.FindFiles(fname) and see what it returns. Do you have an extension on your service script? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bruno.lehyaric at gmail.com Tue Jul 20 15:04:18 2010 From: bruno.lehyaric at gmail.com (Pro) Date: Tue, 20 Jul 2010 15:04:18 +0200 Subject: [python-win32] PyWin32 sur intel xeon 64-bit Message-ID: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> Hi every body, I'm migrating from windows 32bit to 64bit on intel platform. I wonder if PyWin32 works well on intel 64 bit? Is somebody in the same case here? Regards, Bruno. From mc at mclaveau.com Tue Jul 20 15:42:25 2010 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 20 Jul 2010 15:42:25 +0200 Subject: [python-win32] PyWin32 sur intel xeon 64-bit In-Reply-To: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> References: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> Message-ID: <6498AE34CA5B4B549C8E0C3BCC506A39@MCI1330> Hello ! No problem. I use pywin32 on a Xeon with Windows-7-64 bits, without problem. One trick : do not use IE-64 (only IE-32). It is all. Bonjour ! Pas de probl?me. J'utilise, entre autres, PyWin32 sur un Xeon avec Windows-7-64 bits, sans probl?mes. Un truc : ne jamais utilise IE-64 (toujours IE-32). C'est tout. @-salutations -- Michel Claveau From timr at probo.com Tue Jul 20 18:17:32 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Jul 2010 09:17:32 -0700 Subject: [python-win32] pywin32 services In-Reply-To: References: <4C44D494.1070506@probo.com> <4C44DB02.1030404@probo.com> Message-ID: <4C45CC1C.2020801@probo.com> Michael Mileusnich wrote: > > My apologies I was incorrect. fname is being set to C:\Program > Files\HQSystem\bin\hqmonitor.exe but alas the directory was empty. I > corrected this however I still cannot get my services to start. > Currently I use an example that invokes > win32serviceutil.HandleCommandLine(MyService) but all that seems to do > (on my python trace program) is give back the usage. If I try to > 'start' the service I get my service was unable to respond in a timely > fashion error. Well, wait a minute. How is that possible? How could "fname" get the wrong path? It was fetching the program's name from sys.argv[0], which it should have fetched from the command line that started the service. Did you move the directory after you did the original service creation? Remember that the path to your service is stored in the registry. I hope it's obvious that this path MUST be correct if you plan to have Windows start the service on its own. > Correct my I am wrong but all Windows looks for is the SvcDoRun? No, that's not right. You need to remember the pieces that are involved here. Windows doesn't have any clue about Python. It's just running your service as a standard executable. SvcDoRun is just a Python function, which happens to be called by the PyWin32 service framework. Windows services work by receiving messages from the operating system -- messages that tell the service what to do. There are messages for start, stop, and pause, among others. In response to the "start" message, the Python framework will eventually call SvcRun, which then calls your SvcDoRun. Just because Python makes it easy, that doesn't change the way services work. The registry must be correct, and your service must operate like a normal executable. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Marc-Andre.Belzile at autodesk.com Tue Jul 20 18:26:16 2010 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Tue, 20 Jul 2010 09:26:16 -0700 Subject: [python-win32] sys.path and PyWin32 scripting engine In-Reply-To: <4C44A951.7070406@probo.com> References: <4C44A951.7070406@probo.com> Message-ID: I'm referring to Python Active Scripting engines available in pywin32. I'm creating them through COM, so I don't tknow if the ActiveX goes through Py_NewInterpreter or not. -mab -----Original Message----- From: python-win32-bounces+marc-andre.belzile=autodesk.com at python.org [mailto:python-win32-bounces+marc-andre.belzile=autodesk.com at python.org] On Behalf Of Tim Roberts Sent: Monday, July 19, 2010 3:37 PM To: python-win32 at python.org Subject: Re: [python-win32] sys.path and PyWin32 scripting engine Marc-Andre Belzile wrote: > > > > Is the value of sys.path private for each new scripting engine I > create ? Or is it global value ? > > > > According to my test results, any new paths added to sys.path from a > specific engine seems to be available to others. Is it the expected > behavior ? > I'm not sure what you mean by "new scripting engine". Modules are shared between all interpreters in a single process, but when you call Py_NewInterpreter, it is supposed to get its own private copy of sys.modules and sys.path (among several others). Can you be more specific? -- 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 timr at probo.com Tue Jul 20 18:37:34 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Jul 2010 09:37:34 -0700 Subject: [python-win32] PyWin32 sur intel xeon 64-bit In-Reply-To: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> References: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> Message-ID: <4C45D0CE.4040503@probo.com> Pro wrote: > Hi every body, > > I'm migrating from windows 32bit to 64bit on intel platform. > I wonder if PyWin32 works well on intel 64 bit? > > Is somebody in the same case here? Like Michel, I use the 32-bit Python distribution on my 64-bit systems extensively, without any problems. There is a native 64-bit version of PyWin32, but I've never tried it, mostly because there has never been a need. Some day.. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Jul 20 18:45:51 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Jul 2010 09:45:51 -0700 Subject: [python-win32] sys.path and PyWin32 scripting engine In-Reply-To: References: <4C44A951.7070406@probo.com> Message-ID: <4C45D2BF.7020409@probo.com> Marc-Andre Belzile wrote: > I'm referring to Python Active Scripting engines available in pywin32. I'm creating them through COM, so I don't tknow if the ActiveX goes through Py_NewInterpreter or not. Active Scripting creates Python as an out-of-process COM server. That means there will be one Python process fielding all of these requests. If you are creating new instances each time, I would have expected each one to be its own interpreter, but your evidence suggests otherwise. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From planders at gmail.com Tue Jul 20 19:08:47 2010 From: planders at gmail.com (Preston Landers) Date: Tue, 20 Jul 2010 12:08:47 -0500 Subject: [python-win32] PyWin32 sur intel xeon 64-bit In-Reply-To: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> References: <5E37864F-8CC0-4CB4-A7A2-9E471DAB99CF@gmail.com> Message-ID: On Tue, Jul 20, 2010 at 8:04 AM, Pro wrote: > Hi every body, > > I'm migrating from windows 32bit to 64bit on intel platform. > I wonder if PyWin32 works well on intel 64 bit? > > Is somebody in the same case here? > > > Regards, > > Bruno. > Keep in mind that "PyWin32" is the name of the product / package, but it can be deployed in both 32 bit and 64 bit configurations. In general, using a 32 bit Python + PyWin32 works just fine on 64 bit Windows. However there are a couple of very specific things that require a 64 bit build of Python and PyWin32 (and any other extensions) when running on a 64 bit server. One is running an ISAPI web server extension like iis_wsgi. (Running iis_wsgi may also require a tweak to Python 2.6.5's extension compiling file to fix the inclusion of Visual C runtime in the DLL manifest, but that's a bug/issue in Python, not PyWin32.) The other (I'm not 100% certain about this) is writing a Windows Explorer extension in Python. There may be a few other odds and ends like that which require 64 bit, but if you don't use / need those features, then you don't need to have 64 bit Python. I haven't seen any problems resulting from 64 bit deployment. It works great for me. Hope this helps, Preston -------------- next part -------------- An HTML attachment was scrubbed... URL: From justmike2000 at gmail.com Wed Jul 21 05:06:31 2010 From: justmike2000 at gmail.com (Michael Mileusnich) Date: Tue, 20 Jul 2010 22:06:31 -0500 Subject: [python-win32] pywin32 services In-Reply-To: References: <4C44D494.1070506@probo.com> <4C44DB02.1030404@probo.com> <4C45CC1C.2020801@probo.com> Message-ID: Issues: I figured fname was throwing an exception due to the fact I did not qualify .exe at the end of my command. Regardless, upon further investigation using a simple example such as: """ The most basic (working) CherryPy 3.1 Windows service possible. Requires Mark Hammond's pywin32 package. """ import cherrypy import win32serviceutil import win32service class HelloWorld: """ Sample request handler class. """ @cherrypy.expose def index(self): return "Hello world!" class MyService(win32serviceutil.ServiceFramework): """NT Service.""" _svc_name_ = "CherryPyService" _svc_display_name_ = "CherryPy Service" def SvcDoRun(self): cherrypy.tree.mount(HelloWorld(), '/') # in practice, you will want to specify a value for # log.error_file below or in your config file. If you # use a config file, be sure to use an absolute path to # it, as you can't be assured what path your service # will run in. cherrypy.config.update({ 'global':{ 'log.screen': False, 'engine.autoreload.on': False, 'engine.SIGHUP': None, 'engine.SIGTERM': None } }) cherrypy.engine.start() cherrypy.engine.block() def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) cherrypy.engine.exit() self.ReportServiceStatus(win32service.SERVICE_STOPPED) # very important for use with py2exe # otherwise the Service Controller never knows that it is stopped ! if __name__ == '__main__': win32serviceutil.HandleCommandLine(MyService) The service doe not start and gives me the untimely fashion error when win32servileutil calls win32service.StartService(hs, None). -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Jul 21 05:07:35 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 21 Jul 2010 13:07:35 +1000 Subject: [python-win32] sys.path and PyWin32 scripting engine In-Reply-To: <4C45D2BF.7020409@probo.com> References: <4C44A951.7070406@probo.com> <4C45D2BF.7020409@probo.com> Message-ID: <4C466477.9080005@gmail.com> On 21/07/2010 2:45 AM, Tim Roberts wrote: > Marc-Andre Belzile wrote: >> I'm referring to Python Active Scripting engines available in pywin32. I'm creating them through COM, so I don't tknow if the ActiveX goes through Py_NewInterpreter or not. > > Active Scripting creates Python as an out-of-process COM server. The Active Scripting implementation should register so that inproc or out of proc instances can be created (which is the default for all pywin32 implemented COM objects). By default, most things which consume script engines (eg, IE, IIS) create inproc engines. Hence, a single OS process which creates multiple script engines is sharing the same Python interpreter between instances. Py_NewInterpreter is not used by pywin32's COM support. This means a single OS process using multiple scripting engines will have each engine instance sharing the same Python 'environment' (ie, sys.path, loaded modules, etc). If you have control over the host and really want the isolated behaviour, you could try explicitly requesting an out of proc engine when calling CoCreateInstance. HTH, Mark From skippy.hammond at gmail.com Wed Jul 21 05:10:39 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 21 Jul 2010 13:10:39 +1000 Subject: [python-win32] pywin32 services In-Reply-To: References: <4C44D494.1070506@probo.com> <4C44DB02.1030404@probo.com> <4C45CC1C.2020801@probo.com> Message-ID: <4C46652F.3020100@gmail.com> On 21/07/2010 1:06 PM, Michael Mileusnich wrote: > The service doe not start and gives me the untimely fashion error when > win32servileutil calls win32service.StartService(hs, None). While pywin32 attempts to catch most errors, that 'untimely fashion' error generally means it failed to do so (or failed to do so correctly). You might like to check the Windows event log to see if any error information is written there... Cheers, Mark From erik at supportprofessionals.nl Wed Jul 21 09:25:50 2010 From: erik at supportprofessionals.nl (Erik Oosterwaal) Date: Wed, 21 Jul 2010 09:25:50 +0200 Subject: [python-win32] Python in classic ASP Message-ID: <83C373B33E28C0459A9207E7077E1833DCB80F@aristoteles.supportprofessionals.local> Hi All , I'm developing webapplications in classic ASP, currently in VBscript , and making extensive use of WSCs to separate code from GUI. Because we want to transfer over to Python, we are currently trying to implement parts of our main project into python, to get familiar with the language. In the future we'd like to use Python for new projects all together (outside of classic asp). For now we're still stuck with the classic asp environment. In a WSC you can implement the usual ASP objects with the statement: Now, the Python code in my WSC works fine, but as soon as I try to use an ASP object or object method like, Response .Write() in the WSC , it fails: error '80020009' Exception occurred. /tools/python.asp, line 9 I have attached a WSC and an ASP page that work, except for the usual ASP objects, I hope some of you can shed some light on this for me, information about Python in a WSC from classic AP is pretty scarce on the Internet. Please note that I added .txt to the usual file extentions to prevent the files from being blocked. (come to think of it, I don't even know if attachments work in a post to this mailing list, but I guess I'll find that out in a minute) Thanks in advance, and kind regards, Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: python.wsc.txt URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: python.asp.txt URL: From chap8330 at hotmail.com Wed Jul 21 18:22:11 2010 From: chap8330 at hotmail.com (Andrew C) Date: Wed, 21 Jul 2010 12:22:11 -0400 Subject: [python-win32] Call was rejected by callee. Message-ID: I have a script on my server that is performing a win32com operation to generate a MS Word document, and I am getting an error stating: (-2147418111, 'Call was rejected by callee', None,None). How can I get around this error? What can cause it? I am using python 2.6. Code below Thanks AC def CreateWordDocument(bodyText,graphicsPath, FileName): # create word application objWord = win32.gencache.EnsureDispatch('Word.Application') # don't show program objWord.Visible = False #create new word doc objDoc = objWord.Documents.Add() # format the text style objDoc.Content.Font.Name = "Arial" # <--- fails here objDoc.Content.Font.Bold = 1 # <--- fails here objDoc.Content.Font.Size = 12 # <--- fails here # write information objSelection = objWord.Selection objSelection.TypeText(bodyText[0]) objSelection.TypeParagraph() objShape = objSelection.InlineShapes.AddPicture(graphicsPath[0], False, True) objSelection.TypeParagraph() objSelection.TypeText(bodyText[1]) objSelection.TypeParagraph() objShape = objSelection.InlineShapes.AddPicture(graphicsPath[1], False, True) objSelection.TypeParagraph() objSelection.TypeText(bodyText[2]) objSelection.TypeParagraph() objShape = objSelection.InlineShapes.AddPicture(graphicsPath[2], False, True) objSelection.TypeParagraph() objSelection.TypeText(bodyText[3]) objSelection.TypeParagraph() objShape = objSelection.InlineShapes.AddPicture(graphicsPath[3], False, True) objSelection.TypeParagraph() _________________________________________________________________ The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 21 18:47:47 2010 From: timr at probo.com (Tim Roberts) Date: Wed, 21 Jul 2010 09:47:47 -0700 Subject: [python-win32] pywin32 services In-Reply-To: References: <4C44D494.1070506@probo.com> <4C44DB02.1030404@probo.com> <4C45CC1C.2020801@probo.com> Message-ID: <4C4724B3.7060202@probo.com> Michael Mileusnich wrote: > > I figured fname was throwing an exception due to the fact I did not > qualify .exe at the end of my command. Regardless, upon further > investigation using a simple example such as: > ... > The service doe not start and gives me the untimely fashion error when > win32servileutil calls win32service.StartService(hs, None). I don't see anything immediately wrong with that. You're going to need to talk to the CherryPy list. They are a good group of people, and they can confirm that your version numbers are latest and greatest. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From FrekingJohnA at JohnDeere.com Thu Jul 22 05:01:44 2010 From: FrekingJohnA at JohnDeere.com (Freking John) Date: Thu, 22 Jul 2010 11:01:44 +0800 Subject: [python-win32] pywin32-214 DLL install error Message-ID: <75C2C7D8B5B1DB47B1191011B121700C2DFD7606B5@enhbeijing3.jdnet.deere.com> Hi, I'm running XP SP3 and Python 2.6.2 and I'm trying to install pywin32-214 but it fails to load a DLL. The following is the error message I get at the end of the install. Traceback (most recent call last): File "", line 601, in File "", line 313, in install ImportError: DLL load failed: The specified module could not be found. When I try to use the module in a python program I get the following error. Traceback (most recent call last): File "C:\WorkArea\Python\excel2007", line 2, in import win32com.client as win32 File "C:\Python26\lib\win32com\__init__.py", line 5, in import win32api, sys, os ImportError: DLL load failed: The specified module could not be found. >>> I have tried to uninstall and reinstall install pywin32 but that didn't work. And I have tried moving two DLLs, Pythoncom26.dll and PyWinTypes26.dll, into the system32 directory which also didn't work. Thanks, John Freking -------------- next part -------------- An HTML attachment was scrubbed... URL: From trent at snakebite.org Fri Jul 23 17:48:05 2010 From: trent at snakebite.org (Trent Nelson) Date: Fri, 23 Jul 2010 11:48:05 -0400 Subject: [python-win32] I'm getting outfoxed by an ActiveX control... Message-ID: <4C49B9B5.4000807@snakebite.org> Howdy folks, I'm getting outfoxed by a pesky ActiveX control that keeps bombing out with a 'Catastrophic failure' as soon as I try and interact with it: >>> from win32com.client import * >>> d = Dispatch('TWS.TwsCtrl.1') >>> d >>> d.connect('', 7496, 0) pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) >>> import tws >>> de = DispatchWithEvents('TWS.TwsCtrl.1', tws.TwsEvents) >>> de >>> de.connect('', 7496, 0) pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) I came across [1], which notes that 'Catastrophic failure' upon first invoking an ActiveX method is a good indication that the component needs an event loop. It goes on to suggest some wx.activex-fu along the lines of: >>> import wx, wx.activex >>> app = wx.PySimpleApp() >>> f = wx.Frame(None, -1, "") >>> clsid = wx.activex.CLSID('TWS.TwsCtrl.1') *** axw = wx.activex.ActiveXWindows(f, clsid) >>> wx.activex.GernerateAXModule(axw, 'Tws', '.', verbose=True) Unfortunately, if I run that code, it causes python.exe to crash at the *** line above. I've never tried to interface with an ActiveX module that requires an event-loop before, so I'm out of my COM-comfort zone. FWIW, if you drop the OCX onto a VB form, it works fine. However, trying to programmatically interact with the component with, say, VBScript or Perl's Win32::OLE yields the same 'Catastrophic failure' result I'm getting with Python. Relevant files are available here: http://wind.teleri.net/~trent/tws.zip Shipped with the module: Tws_i.h Tws.idl Tws.ocx ComPropAccessor.h Files I've added: tws.py The tws.py is simply the output of makepy, with an additional TwsEvents class that I added in order to try DispatchWithEvents(). Any assistance would be appreciated. Regards, Trent. [1]: http://www.wiredfool.com/2006/11/18/python-and-com-components/ From timr at probo.com Fri Jul 23 20:29:25 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Jul 2010 11:29:25 -0700 Subject: [python-win32] I'm getting outfoxed by an ActiveX control... In-Reply-To: <4C49B9B5.4000807@snakebite.org> References: <4C49B9B5.4000807@snakebite.org> Message-ID: <4C49DF85.2090608@probo.com> Trent Nelson wrote: > I'm getting outfoxed by a pesky ActiveX control that keeps bombing out > with a 'Catastrophic failure' as soon as I try and interact with it: > > >>> from win32com.client import * > >>> d = Dispatch('TWS.TwsCtrl.1') > >>> d > > >>> d.connect('', 7496, 0) > > pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) 8000FFFF. That's basically an error that says "something bad happened, but we're not sure what it was." Also called "anyone get the license number of that truck that hit me?" > I came across [1], which notes that 'Catastrophic failure' upon first > invoking an ActiveX method is a good indication that the component needs > an event loop. It goes on to suggest some wx.activex-fu along the lines of: > > >>> import wx, wx.activex > >>> app = wx.PySimpleApp() > >>> f = wx.Frame(None, -1, "") > >>> clsid = wx.activex.CLSID('TWS.TwsCtrl.1') > *** axw = wx.activex.ActiveXWindows(f, clsid) > >>> wx.activex.GernerateAXModule(axw, 'Tws', '.', verbose=True) That doesn't run an event loop. It might set up a message queue, but in order to run an event loop and cause window messages to be dispatched, you have to call app.MainLoop(). Is this a GUI component? It's difficult for me to tell. If it is a GUI component, then you can't just instantiate it in empty space. You have to host it inside some GUI application. I see that it is a socket-based component. If they are using asynchronous socket processing, that also requires that the event loop be actively dispatching. If this expects to be part of a GUI application, then you are going to need to write a GUI application for it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From trent at snakebite.org Fri Jul 23 22:07:38 2010 From: trent at snakebite.org (Trent Nelson) Date: Fri, 23 Jul 2010 16:07:38 -0400 Subject: [python-win32] I'm getting outfoxed by an ActiveX control... In-Reply-To: <4C49DF85.2090608@probo.com> References: <4C49B9B5.4000807@snakebite.org> <4C49DF85.2090608@probo.com> Message-ID: <4C49F68A.90404@snakebite.org> On 23-Jul-10 2:29 PM, Tim Roberts wrote: > Trent Nelson wrote: >> >>> import wx, wx.activex >> >>> app = wx.PySimpleApp() >> >>> f = wx.Frame(None, -1, "") >> >>> clsid = wx.activex.CLSID('TWS.TwsCtrl.1') >> *** axw = wx.activex.ActiveXWindows(f, clsid) >> >>> wx.activex.GernerateAXModule(axw, 'Tws', '.', verbose=True) > > That doesn't run an event loop. It might set up a message queue, but in > order to run an event loop and cause window messages to be dispatched, > you have to call app.MainLoop(). Yeah, unfortunately, I can't get far enough to call app.MainLoop() -- that wx.activex.ActiveXWindows(f, clsid) line crashes python.exe. > Is this a GUI component? That's what's annoying -- it shouldn't be (the API is data-driven, it doesn't expose any UI controls), but it looks like it's been written as an ActiveX GUI component anyway. (I think the target audience for the ActiveX component is VB developers, so the developer use case they're targeting is "drag tws.ocx onto your form".) They provide C++ and Java socket-oriented interfaces as well, so I'll have a play around with those instead. Thanks for confirming my suspicions. Regards, Trent. From keating at acm.org Sun Jul 25 14:13:14 2010 From: keating at acm.org (Paul Keating) Date: Sun, 25 Jul 2010 14:13:14 +0200 Subject: [python-win32] Call was rejected by callee. References: Message-ID: <012a01cb2bf3$243bfeb0$4601a8c0@vuurpijlhuisje.local> >> objDoc.Content.Font.Name = "Arial" # <--- fails here It ought to work. Switch Visible on so that you can see what is happening as you step through the code. I suspect that Word is popping up a dialogue box (about recovered files, perhaps) that you cannot see, and is refusing to do some things until the popup is dismissed. If that doesn't help, check that objDoc.Content is returning what you think it does. ----- Original Message ----- From: Andrew C From FrekingJohnA at JohnDeere.com Mon Jul 26 03:18:12 2010 From: FrekingJohnA at JohnDeere.com (Freking John) Date: Mon, 26 Jul 2010 09:18:12 +0800 Subject: [python-win32] pywin32-214 DLL install error In-Reply-To: <000d01cb2ab6$01723ef0$4601a8c0@vuurpijlhuisje.local> References: <75C2C7D8B5B1DB47B1191011B121700C2DFD7606B5@enhbeijing3.jdnet.deere.com> <000d01cb2ab6$01723ef0$4601a8c0@vuurpijlhuisje.local> Message-ID: <75C2C7D8B5B1DB47B1191011B121700C2DFD7606B8@enhbeijing3.jdnet.deere.com> Paul, Thanks that worked great. But, I don't understand what you mean by the import hook doesn't work properly. The .pyd files were in the site-packages subfolders so why couldn't Python find them? Thanks, John Freking From: Paul Keating [mailto:keating at acm.org] Sent: Saturday, July 24, 2010 6:26 AM To: Freking John Subject: Re: [python-win32] pywin32-214 DLL install error You're on the right track with your focus on .dlls but I'd say the loader can't find a .pyd (which is a .dll really) that win32api wants. A brute-force solution is to search for win32*.pyd and *winxp*.pyd in python26 and subtree (which will be in site-packages\win32 and site-packages\pythonwin), and copy them next to python.exe. It should be a total of 30 files. This is klugy and ugly but it may work. (It's also easy to back out if it doesn't work!) I support an embedded-Python environment where the vendor's import hook that doesn't quite work properly with packages, so I have to do that routinely. If it does work then you can ask again here for a tidier solution. Paul Keating ----- Original Message ----- From: Freking John To: 'python-win32 at python.org' Sent: Thursday, July 22, 2010 5:01 AM Subject: [python-win32] pywin32-214 DLL install error Hi, I'm running XP SP3 and Python 2.6.2 and I'm trying to install pywin32-214 but it fails to load a DLL. The following is the error message I get at the end of the install. Traceback (most recent call last): File "", line 601, in File "", line 313, in install ImportError: DLL load failed: The specified module could not be found. When I try to use the module in a python program I get the following error. Traceback (most recent call last): File "C:\WorkArea\Python\excel2007", line 2, in import win32com.client as win32 File "C:\Python26\lib\win32com\__init__.py", line 5, in import win32api, sys, os ImportError: DLL load failed: The specified module could not be found. >>> I have tried to uninstall and reinstall install pywin32 but that didn't work. And I have tried moving two DLLs, Pythoncom26.dll and PyWinTypes26.dll, into the system32 directory which also didn't work. Thanks, John Freking ________________________________ _______________________________________________ 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 python at bdurham.com Mon Jul 26 22:31:47 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 26 Jul 2010 16:31:47 -0400 Subject: [python-win32] Possible to update exe file properties and/or icon via the win32api library? Message-ID: <1280176307.6527.1386838237@webmail.messagingengine.com> Is it possible to update an exe file's properties and/or icon file via the win32api library? By exe file properties I mean the properties typically set via a resource file when an exe file is created. Example properties are what one would see if they right clicked on a file in Windows Explorer and chose the Properties dialog. Sample exe file properties: - product name - product version - product description - copyright - exe icon Use case: We have a single exe whose file properties we would like to customize for specific customers. An alternative question would be is there a way to update an exe's file properties using an external resource file? Or would I be better off finding a Windows utility that might allow me to script exe resource file updates? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jul 26 22:48:32 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 26 Jul 2010 13:48:32 -0700 Subject: [python-win32] Possible to update exe file properties and/or icon via the win32api library? In-Reply-To: <1280176307.6527.1386838237@webmail.messagingengine.com> References: <1280176307.6527.1386838237@webmail.messagingengine.com> Message-ID: <4C4DF4A0.7080608@probo.com> python at bdurham.com wrote: > Is it possible to update an exe file's properties and/or icon file via > the win32api library? By exe file properties I mean the properties > typically set via a resource file when an exe file is created. Example > properties are what one would see if they right clicked on a file in > Windows Explorer and chose the Properties dialog. > > Sample exe file properties: > - product name > - product version > - product description > - copyright > - exe icon > > Use case: We have a single exe whose file properties we would like to > customize for specific customers. > > An alternative question would be is there a way to update an exe's > file properties using an external resource file? > > Or would I be better off finding a Windows utility that might allow me > to script exe resource file updates? > There are many Resource Editors available on the web today that can handle replacing resources in an existing executable, although there are no APIs for doing so. See, for example, "resource hacker". There are many valid uses for having multiple external resource DLLs. That's the way internationalization is often done. You have one resource-only DLL for each language, and the main program looks up resources there first. But if you want to change what Windows Explorer shows, then you have little choice other than modifying the executable file itself. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Tue Jul 27 09:01:52 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 27 Jul 2010 17:01:52 +1000 Subject: [python-win32] Possible to update exe file properties and/or icon via the win32api library? In-Reply-To: <1280176307.6527.1386838237@webmail.messagingengine.com> References: <1280176307.6527.1386838237@webmail.messagingengine.com> Message-ID: <4C4E8460.1040306@gmail.com> On 27/07/2010 6:31 AM, python at bdurham.com wrote: > Is it possible to update an exe file's properties and/or icon file via > the win32api library? Kinda - although it is pretty painful to use. To get started, check out the 'verstamp.py' utility included with pywin32 and if you want to update the icon etc, be prepared to read the win32 docs for BeginUpdateResource etc and alot of experimentation (although digging into the py2exe source code might be helpful there as it updates icons and string resources using the same basic functions - although not via pywin32) Cheers, Mark From vernondcole at gmail.com Sat Jul 31 09:46:26 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Sat, 31 Jul 2010 01:46:26 -0600 Subject: [python-win32] Announcing adodbapi version 2.4.0 -- now with COLUMN NAME data access Message-ID: Announcing a new version of adodbapi... [ for those who may not know... [ adodbapi is a pure Python package which fully implements the PEP-249 db-api [ using Microsoft ADO/db. [ It runs on CPython versions 2.3 and later, IronPython 2.6 and later, [ or Python 3.0 and later. http://sourceforge.net/projects/adodbapi I have often been frustrated by the need to count '?' marks for input parameters and remembering column numbers to get my SQL output. This release fixes that by allowing the use of 'named' parameters as an option, and by returning 'SQLrow' objects which allow the use of column names. This version includes a distutils setup.py file, so installation is easy. Just 1) unzip 2) "cd" to the directory you just unzipped. 2) Execute the command: python setup.py install using the python distribution of your choice. It even runs 2to3 automatically if you run it using a 3.n Python. (Why didn't I do this years ago?) NOTE: you must have already installed pywin32. This will upgrade your existing version. Here's what's new............................ * adodbapi version 2.4.0 -- in this version, "fetchall()" and "fetchmany()" return an SQLrows object ...which emulates a sequence of SQLrow objects. "fetchone()" or the cursor's "next()" method return an SQLrow object. An SQLrow object emulates a tuple of data fields. An SQLrow object also appears to have an attribute for each column of data. therefore... >>> import adodbapi >>> myConnection = adodbapi.connection('someDSN') >>> cur = myConnection.cursor() >>> cur.execute("select name, rank, serialNumber from soldiers") >>> row = cur.fetchone() >>> assert row[0] == row['name'] >>> assert row[1] == row.rank >>> rows = cur.fecthall() >>> assert rows[4,'serialNumber'] == rows[4][2] * adodbapi version 2.3.0 -- this is includes major refactoring and specifically adds features for django support, including the ability for the programmer to change ado's SQL "paramstyle" at run time to select between 'qmark', 'format' and 'named' methods of passing SQL parameters. ** also, in response to user requests, adodbapi will now use client-side cursors by default. This will make rowcount and stored procedure return parameter values more readily available. -------------- next part -------------- An HTML attachment was scrubbed... URL: