From andrea.gavana at gmail.com Fri Dec 1 14:13:57 2006 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Fri, 1 Dec 2006 18:13:57 +0500 Subject: [python-win32] PythonWin And Excel Problem Message-ID: Hi All, I am having some problems in running a very simple python script, which prints some numbers in an Excel spreadsheet. The numbers are stored in a list. I know that the numbers are different (random generated), but when I open the Excel file I get a column of data with all the numbers equal to the first item in the python list. I attach a very simple script that reproduces the problem. I am using Python 2.5, PythonWin build 210, Windows XP. Am I missing something? Thank you for every hint. import os import random from win32com.client import Dispatch therand = [] for ii in xrange(10): therand.append(random.random()) xlsapp = Dispatch("Excel.Application") wb = xlsapp.Workbooks.Add() xlsapp.Worksheets.Item(2).Delete() xlsapp.Worksheets.Item(1).Delete() sheet = wb.Sheets[0] sheet.Name = "Data" sheet.Range("A1:A10").Value = therand excelfile = "C:/HelloWin32.xls" wb.SaveAs(excelfile) wb.Close() xlsapp.Quit() os.startfile(excelfile) Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ From msherman77 at yahoo.com Fri Dec 1 14:40:04 2006 From: msherman77 at yahoo.com (Michael S) Date: Fri, 1 Dec 2006 08:40:04 -0500 (EST) Subject: [python-win32] PythonWin And Excel Problem In-Reply-To: Message-ID: <754125.49279.qm@web88301.mail.re4.yahoo.com> First of all you should call the random.seed() function. That was at least what I?ve always done. seed([x]) Initialize the basic random number generator. Second of all, calling random.random() will give you this: random() Return the next random floating point number in the range [0.0, 1.0). In your loop try to call random.randit() and call the random.seed() beforehand. HTH, Michael --- Andrea Gavana wrote: > Hi All, > > I am having some problems in running a very > simple python script, > which prints some numbers in an Excel spreadsheet. > The numbers are > stored in a list. I know that the numbers are > different (random > generated), but when I open the Excel file I get a > column of data with > all the numbers equal to the first item in the > python list. > I attach a very simple script that reproduces the > problem. > > I am using Python 2.5, PythonWin build 210, Windows > XP. Am I missing > something? Thank you for every hint. > > import os > import random > > from win32com.client import Dispatch > > therand = [] > for ii in xrange(10): > therand.append(random.random()) > > xlsapp = Dispatch("Excel.Application") > wb = xlsapp.Workbooks.Add() > > xlsapp.Worksheets.Item(2).Delete() > xlsapp.Worksheets.Item(1).Delete() > sheet = wb.Sheets[0] > sheet.Name = "Data" > sheet.Range("A1:A10").Value = therand > > excelfile = "C:/HelloWin32.xls" > > wb.SaveAs(excelfile) > wb.Close() > xlsapp.Quit() > > os.startfile(excelfile) > > > Andrea. > > "Imagination Is The Only Weapon In The War Against > Reality." > http://xoomer.virgilio.it/infinity77/ > -- > http://mail.python.org/mailman/listinfo/python-list > From msherman77 at yahoo.com Fri Dec 1 15:57:45 2006 From: msherman77 at yahoo.com (Michael S) Date: Fri, 1 Dec 2006 09:57:45 -0500 (EST) Subject: [python-win32] PythonWin And Excel Problem In-Reply-To: Message-ID: <20061201145746.74468.qmail@web88304.mail.re4.yahoo.com> Andrea, Also, could it be that when you do the following: sheet.Range("A1:A10").Value = therand you actually initialize all 10 cells to the first element of the array? Try to iterate and initialize every cell separately. Michael --- Andrea Gavana wrote: > Hi All, > > I am having some problems in running a very > simple python script, > which prints some numbers in an Excel spreadsheet. > The numbers are > stored in a list. I know that the numbers are > different (random > generated), but when I open the Excel file I get a > column of data with > all the numbers equal to the first item in the > python list. > I attach a very simple script that reproduces the > problem. > > I am using Python 2.5, PythonWin build 210, Windows > XP. Am I missing > something? Thank you for every hint. > > import os > import random > > from win32com.client import Dispatch > > therand = [] > for ii in xrange(10): > therand.append(random.random()) > > xlsapp = Dispatch("Excel.Application") > wb = xlsapp.Workbooks.Add() > > xlsapp.Worksheets.Item(2).Delete() > xlsapp.Worksheets.Item(1).Delete() > sheet = wb.Sheets[0] > sheet.Name = "Data" > sheet.Range("A1:A10").Value = therand > > excelfile = "C:/HelloWin32.xls" > > wb.SaveAs(excelfile) > wb.Close() > xlsapp.Quit() > > os.startfile(excelfile) > > > Andrea. > > "Imagination Is The Only Weapon In The War Against > Reality." > http://xoomer.virgilio.it/infinity77/ > -- > http://mail.python.org/mailman/listinfo/python-list > From smithbk at aecl.ca Fri Dec 1 15:52:22 2006 From: smithbk at aecl.ca (Smith, Brian (CR)) Date: Fri, 1 Dec 2006 09:52:22 -0500 Subject: [python-win32] PythonWin And Excel Problem Message-ID: Hi Andrea, > therand = [] > for ii in xrange(10): > therand.append(random.random()) > ... > sheet.Range("A1:A10").Value = therand I believe that when setting the value for a range, you must supply a list of row data, where each piece of row data is a list of column data. In other words, a list of lists. I think your problem will be fixed if you change your code to for ii in xrange(10): therand.append((random.random(),)) Brian CONFIDENTIAL AND PRIVILEGED INFORMATION NOTICE This e-mail, and any attachments, may contain information that is confidential, subject to copyright, or exempt from disclosure. Any unauthorized review, disclosure, retransmission, dissemination or other use of or reliance on this information may be unlawful and is strictly prohibited. AVIS D'INFORMATION CONFIDENTIELLE ET PRIVIL?GI?E Le pr?sent courriel, et toute pi?ce jointe, peut contenir de l'information qui est confidentielle, r?gie par les droits d'auteur, ou interdite de divulgation. Tout examen, divulgation, retransmission, diffusion ou autres utilisations non autoris?es de l'information ou d?pendance non autoris?e envers celle-ci peut ?tre ill?gale et est strictement interdite. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061201/1aa1e453/attachment.html From bbands at gmail.com Fri Dec 1 19:34:07 2006 From: bbands at gmail.com (BBands) Date: Fri, 1 Dec 2006 10:34:07 -0800 Subject: [python-win32] DDE problem Message-ID: <6e8360ad0612011034r5cfeb6f4m7e75b9a706dd5ae1@mail.gmail.com> Hello all, Upgraded from 2.4.2 to 2.4.4 and build 205 to 210 this morning. The following snippet worked before the upgrade, but fails now on the commented line with the following message: "error: The server could not be created" import win32ui import dde def getQuote(symbol): """get a quote from a running instance of eSignal""" server = dde.CreateServer() server.Create('eSignalDDE') # fails on this line conversation = dde.CreateConversation(server) conversation.ConnectTo("WINROS", "Last") last = conversation.Request(symbol) return float(last.split("\0")[0]) a = getQuote("$spx") print a Any clues? jab -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. From bbands at gmail.com Fri Dec 1 20:09:27 2006 From: bbands at gmail.com (BBands) Date: Fri, 1 Dec 2006 11:09:27 -0800 Subject: [python-win32] DDE problem Message-ID: <6e8360ad0612011109y3ac6a8bex83c246fdd634fa93@mail.gmail.com> A bit more... The snippet runs in IDLE, but not PythonWin. jab -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. From andykirk at ubermonkey.net Sat Dec 2 10:29:02 2006 From: andykirk at ubermonkey.net (Andrew Kirkpatrick) Date: Sat, 02 Dec 2006 19:59:02 +1030 Subject: [python-win32] shell_view.py problem Message-ID: <4571475E.1010705@ubermonkey.net> Hello, I'm having a play with python on windows and installed pywin32 version 210 for python 2.5. There is a nifty example C:\Python25\Lib\site-packages\win32comext\shell\demos\servers\shell_view.py that creates a virtual folder under the desktop root in windows explorer. When I run it, it registers a COM server to handle this virtual folder, I can see the changes it makes to the registry and the item appears in explorer. However clicking on this item does nothing, focus returns immediately to the desktop root item. I've littered the file with calls to a logging function but nothing ever gets written to the log file. It seems to me that while it works to register itself, it then doesn't get called by windows to handle events from explorer. If anyone can help with this issue I'd be most grateful. Cheers, Andy Kirkpatrick From rwupole at msn.com Sat Dec 2 16:51:41 2006 From: rwupole at msn.com (Roger Upole) Date: Sat, 2 Dec 2006 10:51:41 -0500 Subject: [python-win32] Re: shell_view.py problem Message-ID: Andrew Kirkpatrick wrote: > Hello, I'm having a play with python on windows and installed pywin32 > version 210 for python 2.5. There is a nifty example > C:\Python25\Lib\site-packages\win32comext\shell\demos\servers\shell_view.py > that creates a virtual folder under the desktop root in windows > explorer. When I run it, it registers a COM server to handle this > virtual folder, I can see the changes it makes to the registry and the > item appears in explorer. However clicking on this item does nothing, > focus returns immediately to the desktop root item. I've littered the > file with calls to a logging function but nothing ever gets written to > the log file. It seems to me that while it works to register itself, it > then doesn't get called by windows to handle events from explorer. > > If anyone can help with this issue I'd be most grateful. > > Cheers, > Andy Kirkpatrick It doesn't support the default Open verb invoked by double-clicking. Right click and select Explore, and it will show up as an expandable item. The Scintilla file view that should show up in explorer's right window doesn't work at the moment, but I have some uncommitted changes that allow it to work on XP. Roger From cappy2112 at gmail.com Sun Dec 3 01:29:47 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sat, 2 Dec 2006 16:29:47 -0800 Subject: [python-win32] Console width in characters Message-ID: <8249c4ac0612021629g52ed38f5lc5dd4d6975ce3164@mail.gmail.com> I'm trying to find an API that will give me the width of a cmd console window, in charaters. GetSystemMetrics(SM_CXSCREEN) will return it in pixels- but that doesn't help. If the user resizes the console, I want to be able to adjust the text output of a program I've looked at the WConio package- that may do it, but I'd rather just uses a straight API (if possible), because WConio isn't maintained. Is there an API that returns the number of characters of the "printable area" of a console windows? I'm using Python 2.3.4, and build 202 of PythonWin thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061202/d284c12f/attachment.htm From rwupole at msn.com Sun Dec 3 02:07:15 2006 From: rwupole at msn.com (Roger Upole) Date: Sat, 2 Dec 2006 20:07:15 -0500 Subject: [python-win32] Console width in characters Message-ID: Tony Cappellini wrote: > I'm trying to find an API that will give me the width of a cmd console > window, in charaters. > > GetSystemMetrics(SM_CXSCREEN) will return it in pixels- but that doesn't > help. > > If the user resizes the console, I want to be able to adjust the text output > of a program > > I've looked at the WConio package- that may do it, but I'd rather just uses > a straight API (if possible), because WConio isn't maintained. > > Is there an API that returns the number of characters of the "printable > area" of a console windows? > > I'm using Python 2.3.4, and build 202 of PythonWin > > thanks > The win32console module contains the functions that deal with console window parameters. It was added in build 205, though. Roger From andykirk at ubermonkey.net Sat Dec 2 23:27:17 2006 From: andykirk at ubermonkey.net (Andrew Kirkpatrick) Date: Sun, 03 Dec 2006 08:57:17 +1030 Subject: [python-win32] shell_view.py problem In-Reply-To: References: Message-ID: <4571FDC5.5000206@ubermonkey.net> Roger Upole wrote: > Andrew Kirkpatrick wrote: > >> Hello, I'm having a play with python on windows and installed pywin32 >> version 210 for python 2.5. There is a nifty example >> C:\Python25\Lib\site-packages\win32comext\shell\demos\servers\shell_view.py >> that creates a virtual folder under the desktop root in windows >> explorer... > > It doesn't support the default Open verb invoked by double-clicking. > Right click and select Explore, and it will show up as an expandable > item. The Scintilla file view that should show up in explorer's right window > doesn't work at the moment, but I have some uncommitted changes > that allow it to work on XP. > Roger you're correct, funny thing is the item on the desktop only sports options that launch explorer viewing the desktop, then when I right click on the same item in that explorer window there is a non-default option 'Expand' that triggers the COM server and gives a view of sys.path. (This is on XP, BTW) I'll have to read up about this interface to explorer and its use in python. Is there a good source of info on this? Thanks for your help, Andy From bgailer at alum.rpi.edu Mon Dec 4 22:41:30 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon, 04 Dec 2006 13:41:30 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: References: Message-ID: <4574960A.7030501@alum.rpi.edu> Bokverket wrote: > Hi Bob, > > [snip] Please always reply to the list. Others may be able to provide the next step, we all learn, and I was almost gone for a week and would have left you in the dark. > > So maybe try your Python suggestion, if I can get it to work. You showed it > as Python being started first and then accessing Word, but I suppose that > the other way that people suggested (use VB for dialog boxes, then shell > Python) is OK, too. Can the parameters that were entered in the dialog box > be made accessible to Python? > Shell to start python, and pass command line arguments. Retrieve them in Python using: import sys sys.argv # is a list of the arguments. > Also, I suppose that Python can hold infinitely (almost) long strings, like > a 400 page document? > Limited only by memory. -- Bob Gailer 510-978-4454 From timr at probo.com Mon Dec 4 23:17:06 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 04 Dec 2006 14:17:06 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: <4574960A.7030501@alum.rpi.edu> References: <4574960A.7030501@alum.rpi.edu> Message-ID: <45749E62.7010204@probo.com> Bob Gailer wrote: >> So maybe try your Python suggestion, if I can get it to work. You showed it >> as Python being started first and then accessing Word, but I suppose that >> the other way that people suggested (use VB for dialog boxes, then shell >> Python) is OK, too. Can the parameters that were entered in the dialog box >> be made accessible to Python? >> Shelling to Python is one method, but it is also possible to write a COM server in Python and instantiate it from VB just like any COM object. If you actually need to pass data back and forth, that may be a better way. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Tue Dec 5 01:37:18 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Dec 2006 11:37:18 +1100 Subject: [python-win32] DDE problem In-Reply-To: <6e8360ad0612011109y3ac6a8bex83c246fdd634fa93@mail.gmail.com> Message-ID: <0a2f01c71805$85adc710$110a0a0a@enfoldsystems.local> > A bit more... > > The snippet runs in IDLE, but not PythonWin. Pythonwin itself uses DDE - try starting with /nodde on the command-line and see if that help. Mark From rwupole at msn.com Tue Dec 5 03:36:33 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 4 Dec 2006 21:36:33 -0500 Subject: [python-win32] Re: shell_view.py problem Message-ID: Andrew Kirkpatrick wrote: > Roger Upole wrote: >> Andrew Kirkpatrick wrote: >> >>> Hello, I'm having a play with python on windows and installed pywin32 >>> version 210 for python 2.5. There is a nifty example >>> C:\Python25\Lib\site-packages\win32comext\shell\demos\servers\shell_view.py >>> that creates a virtual folder under the desktop root in windows >>> explorer... >> >> It doesn't support the default Open verb invoked by double-clicking. >> Right click and select Explore, and it will show up as an expandable >> item. The Scintilla file view that should show up in explorer's right window >> doesn't work at the moment, but I have some uncommitted changes >> that allow it to work on XP. >> > > Roger you're correct, funny thing is the item on the desktop only sports > options that launch explorer viewing the desktop, then when I right > click on the same item in that explorer window there is a non-default > option 'Expand' that triggers the COM server and gives a view of > sys.path. (This is on XP, BTW) I'll have to read up about this interface > to explorer and its use in python. Is there a good source of info on this? > > Thanks for your help, > Andy The MSDN docs for shell namespace extensions are your best bet. Also, check MSDN for the interfaces used in shell_view.py, such as IShellFolder. The pythoncom documentation for how you implement these interfaces in a server class is somewhat lacking, however. Most of the docs are focused on the client interfaces. Roger From axiomx11 at gmail.com Wed Dec 6 15:37:49 2006 From: axiomx11 at gmail.com (Axiom X11) Date: Wed, 6 Dec 2006 09:37:49 -0500 Subject: [python-win32] EasyDialogs - typeList Message-ID: <70b542190612060637y53678d84v525545f9590c1339@mail.gmail.com> I am trying to write a dialog the opens a video file. This works: import EasyDialogs file = EasyDialogs.AskFileForOpen(defaultLocation="c:\\", typeList=('avi','mpg','mpeg', )) and outputs a dialog that shows *.avi *.mpg *.mpeg in the selection dropdown. What I want to do is have it show Video Files (*.avi;*.mpg;*.mpeg) This idea is hinted at on this page: http://www.averdevelopment.com/python/EasyDialogs.html But the example doesn't seem to work (or perhaps I don't understand how to use it) When I tried it like this: file = EasyDialogs.AskFileForOpen(defaultLocation="c:\\", typeList=(('C Files (*.c, *.h)', '*.c;*.h'))) The dropdown on the open dialog says *.C Files (*.c, *.h) *.*.c;*.h It just put asterisks in front of whatever values you give it. (And no, the first option does not work, and while the second one does, it breaks if you delete the first one). Any hints on this would be welcomed. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061206/bdf3a444/attachment.html From johnnyloops at gmail.com Wed Dec 6 19:17:39 2006 From: johnnyloops at gmail.com (johnny loops) Date: Wed, 6 Dec 2006 10:17:39 -0800 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks Message-ID: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> I have been pining over implementing what seems to be a VB custom com interface for some time now, so I thought I would post to the list to see if anyone could help. I have a com component on which I have run makepy. The function generates a couple of classes with functions and callbacks that all work fine when I DispatchWithEvents. However there is one interface that I cannot figure out how to use. This interface is only referenced in the vtables section as foo_vtables_dispatch_ = 0 foo_vtables_ = [ (( 'OnFunc1' , 'variable1' , ), 1610678272, (1610678272, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 12 , (3, 0, None, None) , 0 , )), (( 'OnFunc2' , 'variable2' , ), 1610678273, (1610678273, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 16 , (3, 0, None, None) , 0 , )), ] foo is also listed in the VTablesToClassMap and the NamesToIIDMap Now, OnFunc1 and OnFunc2 are callback functions of an interface that I need to implement. Once I implement the interface, I need to pass that object to another com object that will fire callbacks. So reading some of these lists, I thought I should register the interface, create a server, wrap the server and pass it to the other com function. For example: universal.RegisterInterfaces(CLSID,0,2,0,["foo"]) class F: _com_interfaces_=["foo"] _typelib_guid_ = CLSID _typelib_version_ = 2,0 _public_methods_ = [] or ['OnFunc1', 'OnFunc2'] -- i've tried both def OnFunc1: do some stuff def OnFunc2 do some other stuff o=wrap(F) otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) This does not produce any errors, but callbacks to OnFunc1 and OnFunc2 never fire-- and I know they are firing. Also wrapping with a debugging dispatcher adds produces no information. Callbacks to the regularly dispatched com objects do fire. So my question is: Is what I am trying to do possible using win32com? Does this seem like it should work? If not, does anyone have any suggestions using comtypes? I have read that vtable interfaces should be no problem for comtypes, but I can't find much in the way of documentation/examples. Basically, I'm lost here, to the point where I may have to switch to VB (eek)--so any help would be appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061206/ff03d880/attachment.htm From timr at probo.com Wed Dec 6 21:07:13 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 06 Dec 2006 12:07:13 -0800 Subject: [python-win32] EasyDialogs - typeList In-Reply-To: <70b542190612060637y53678d84v525545f9590c1339@mail.gmail.com> References: <70b542190612060637y53678d84v525545f9590c1339@mail.gmail.com> Message-ID: <457722F1.8030308@probo.com> Axiom X11 wrote: > I am trying to write a dialog the opens a video file. > ... > What I want to do is have it show > > Video Files (*.avi;*.mpg;*.mpeg) > > This idea is hinted at on this page: > http://www.averdevelopment.com/python/EasyDialogs.html > But the example doesn't seem to work (or perhaps I don't understand > how to use it) > > When I tried it like this: > > file = EasyDialogs.AskFileForOpen(defaultLocation="c:\\", > typeList=(('C Files (*.c, *.h)', '*.c;*.h'))) Ah, you got trapped by perhaps the greatest Python syntax trap. What you have given to typeList is NOT a tuple of tuples: the outer set of parentheses are interpreted as grouping parens and are discarded. You have it a list with two entries, which is what it displayed. Try this: file = EasyDialogs.AskForFileOpen( defaultLocation="c:\\", typeList=( ('Video Files (*.avi,*.mpg,*.mpeg)', '*.avi;*.mpg;*.mpeg'), ) ) Notice the extra comma inside the outer parens. That's the key. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at ctypes.org Wed Dec 6 21:21:32 2006 From: theller at ctypes.org (Thomas Heller) Date: Wed, 06 Dec 2006 21:21:32 +0100 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks In-Reply-To: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> References: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> Message-ID: johnny loops schrieb: > I have been pining over implementing what seems to be a VB custom com > interface for some time now, so I thought I would post to the list to see if > anyone could help. > > I have a com component on which I have run makepy. The function generates a > couple of classes with functions and callbacks that all work fine when I > DispatchWithEvents. However there is one interface that I cannot figure out > how to use. This interface is only referenced in the vtables section as > > foo_vtables_dispatch_ = 0 > foo_vtables_ = [ > (( 'OnFunc1' , 'variable1' , ), 1610678272, (1610678272, (), [ (36, 1, > None, None) , ], 1 , 1 , 4 , 0 , 12 , (3, 0, None, None) , 0 , )), > (( 'OnFunc2' , 'variable2' , ), 1610678273, (1610678273, (), [ (36, 1, > None, None) , ], 1 , 1 , 4 , 0 , 16 , (3, 0, None, None) , 0 , )), > ] > > foo is also listed in the VTablesToClassMap and the NamesToIIDMap > > Now, OnFunc1 and OnFunc2 are callback functions of an interface that I need > to implement. Once I implement the interface, I need to pass that object to > another com object that will fire callbacks. So reading some of these > lists, I thought I should register the interface, create a server, wrap the > server and pass it to the other com function. > > For example: > universal.RegisterInterfaces(CLSID,0,2,0,["foo"]) > class F: > _com_interfaces_=["foo"] > _typelib_guid_ = CLSID > _typelib_version_ = 2,0 > _public_methods_ = [] or ['OnFunc1', 'OnFunc2'] -- i've tried both > def OnFunc1: > do some stuff > def OnFunc2 > do some other stuff > o=wrap(F) > otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) > > This does not produce any errors, but callbacks to OnFunc1 and OnFunc2 never > fire-- and I know they are firing. Also wrapping with a debugging > dispatcher adds produces no information. Callbacks to the regularly > dispatched com objects do fire. > > So my question is: Is what I am trying to do possible using win32com? Does > this seem like it should work? I cannot comment on this question. > If not, does anyone have any suggestions > using comtypes? I have read that vtable interfaces should be no problem for > comtypes, but I can't find much in the way of documentation/examples. > Basically, I'm lost here, to the point where I may have to switch to VB > (eek)--so any help would be appreciated. I have at least started writing some docs, and posted links to the ctypes users list: This describes how COM interfaces are defined, used, and implemented in comtypes: http://svn.python.org/view/*checkout*/ctypes/trunk/comtypes/docs/com_interfaces.html and this describes the comtypes.client high-level module functionality: http://svn.python.org/view/*checkout*/ctypes/trunk/comtypes/docs/comtypes.client.html I hope these documents have some value. Also I'm willing to help you if you want to try out comtypes. Thomas From johnnyloops at gmail.com Wed Dec 6 23:06:29 2006 From: johnnyloops at gmail.com (johnny loops) Date: Wed, 6 Dec 2006 14:06:29 -0800 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks In-Reply-To: References: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> Message-ID: <2d8e22aa0612061406i7aa2d89cq2cedef71750ee214@mail.gmail.com> Thanks, these references are really helpful, and I think I understand a lot more of the path using comtypes. Continuing with my pseudo code example-- this is what I think I should do: -run GetModule() on the library, which should create the interface foo -Create a class implementing foo -Create object implementing interface foo -Pass the object to the other com function that will fire callbacks to it comtypes.client.GetModule('CLSID that contains foo') class myComObjClass(COMObject): _com_interfaces_ = [foo] def foo_OnFunc1(self, this, variable1): do some stuff on callback def foo_OnFunc2(self, this, variable2): do some other stuff o=myComObjClass() otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) What I'm not sure about is the step that creates the object. Before, when I tried using win32com, I thought I had to wrap a server to pass it-- this didn't work, so I could have been off the mark here. Does this look right? Is it really this easy? From huaxing.wu at guidant.com Thu Dec 7 00:42:24 2006 From: huaxing.wu at guidant.com (Wu, Huaxing (STP)) Date: Wed, 6 Dec 2006 17:42:24 -0600 Subject: [python-win32] Question about os.system Message-ID: <6815D9842896894F9CE2C9D3B19BCA0F917387@STPEVS03.stp.guidant.com> Hi, all, I have some problem using os.system when a command that spawned by os.system itself tries to use os.system. It may be easier to explain with an example. Assume I have 3 python scripts. They are aa.py, bb.py and cc.py. File aa.py (Try to run bb.py using os.system) import os print "in", __file__ sysCode = os.system("bb.py") Print "executing bb.py ", sysCode File bb.py (try to run cc.py using os.system) import os print "in", __file__ sysCode = os.system("cc.py") Print "executing cc.py ", sysCode File cc.py import os print "in", __file__ On command line, run "aa.py" And cc.py never get run. Is there anything wrong in the code? Thank you. Huaxing -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061206/1b7db097/attachment.html From rays at blue-cove.com Thu Dec 7 01:32:46 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Wed, 06 Dec 2006 16:32:46 -0800 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() Message-ID: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> I've been mulling screen capture code. I tried PIL's ImageGrab().grab() (with pymedia) but find PIL's method to be pretty slow, ~4grabs per second max with no other processes. pymedia is pretty quick once I hand it the data. There has to be another way to get a copy or buffer() of the screen DC's data that is faster (I hope). I putsed around with win32gui desktop = win32gui.GetDesktopWindow() dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) but couldn't see how to get at the data via the handle. I've read that ctypes can directly access data by constructing POINTER objects, but I didn't try it. suggestions? Ray From timr at probo.com Thu Dec 7 01:59:23 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 06 Dec 2006 16:59:23 -0800 Subject: [python-win32] Question about os.system In-Reply-To: <6815D9842896894F9CE2C9D3B19BCA0F917387@STPEVS03.stp.guidant.com> References: <6815D9842896894F9CE2C9D3B19BCA0F917387@STPEVS03.stp.guidant.com> Message-ID: <4577676B.3090908@probo.com> Wu, Huaxing (STP) wrote: > > Hi, all, > > I have some problem using os.system when a command that spawned by > os.system itself tries to use os.system. It may be easier to explain > with an example. > > Assume I have 3 python scripts. They are aa.py, bb.py and cc.py. > File aa.py (Try to run bb.py using os.system) > import os > print "in", __file__ > sysCode = os.system("bb.py") > Print "executing bb.py ", sysCode > > File bb.py (try to run cc.py using os.system) > import os > print "in", __file__ > sysCode = os.system("cc.py") > Print "executing cc.py ", sysCode > > File cc.py > import os > print "in", __file__ > > On command line, run "aa.py" > > And cc.py never get run. Is there anything wrong in the code? > Works for me in Windows XP, once I fixed your print/Print confusion. What environment are you in? C:\tmp\x>type aa.py import os print "in", __file__ sysCode = os.system("bb.py") print "executing bb.py ", sysCode C:\tmp\x>type bb.py import os print "in", __file__ sysCode = os.system("cc.py") print "executing cc.py ", sysCode C:\tmp\x>type cc.py import os print "in", __file__ C:\tmp\x>python aa.py in aa.py in C:\tmp\x\bb.py in C:\tmp\x\cc.py executing cc.py 0 executing bb.py 0 C:\tmp\x> -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Dec 7 02:02:41 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 06 Dec 2006 17:02:41 -0800 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() In-Reply-To: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> References: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> Message-ID: <45776831.4070709@probo.com> Ray Schumacher wrote: > I've been mulling screen capture code. I tried PIL's > ImageGrab().grab() (with pymedia) but find PIL's method to be pretty > slow, ~4grabs per second max with no other processes. > pymedia is pretty quick once I hand it the data. > How large is your screen? A 1600x1200 true-color desktop is 8 megabytes worth of pixels, and it can take tens of milliseconds just to copy it over the PCI bus to main memory. > There has to be another way to get a copy or buffer() of the screen > DC's data that is faster (I hope). > > I putsed around with win32gui > desktop = win32gui.GetDesktopWindow() > dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) > but couldn't see how to get at the data via the handle. > You can use BitBlt to copy it to a DIB, but it's not going to be very convenient to work with. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nytrokiss at gmail.com Thu Dec 7 04:07:53 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 6 Dec 2006 19:07:53 -0800 Subject: [python-win32] Question about os.system In-Reply-To: <4577676B.3090908@probo.com> References: <6815D9842896894F9CE2C9D3B19BCA0F917387@STPEVS03.stp.guidant.com> <4577676B.3090908@probo.com> Message-ID: <8a6b8e350612061907k5e02490ck769c26d7a45e96f8@mail.gmail.com> Try Exec with the file handle On 12/6/06, Tim Roberts wrote: > > Wu, Huaxing (STP) wrote: > > > > Hi, all, > > > > I have some problem using os.system when a command that spawned by > > os.system itself tries to use os.system. It may be easier to explain > > with an example. > > > > Assume I have 3 python scripts. They are aa.py, bb.py and cc.py. > > File aa.py (Try to run bb.py using os.system) > > import os > > print "in", __file__ > > sysCode = os.system("bb.py") > > Print "executing bb.py ", sysCode > > > > File bb.py (try to run cc.py using os.system) > > import os > > print "in", __file__ > > sysCode = os.system("cc.py") > > Print "executing cc.py ", sysCode > > > > File cc.py > > import os > > print "in", __file__ > > > > On command line, run "aa.py" > > > > And cc.py never get run. Is there anything wrong in the code? > > > > Works for me in Windows XP, once I fixed your print/Print confusion. > What environment are you in? > > C:\tmp\x>type aa.py > import os > print "in", __file__ > sysCode = os.system("bb.py") > print "executing bb.py ", sysCode > > C:\tmp\x>type bb.py > import os > print "in", __file__ > sysCode = os.system("cc.py") > print "executing cc.py ", sysCode > > C:\tmp\x>type cc.py > import os > print "in", __file__ > > C:\tmp\x>python aa.py > in aa.py > in C:\tmp\x\bb.py > in C:\tmp\x\cc.py > executing cc.py 0 > executing bb.py 0 > > C:\tmp\x> > > -- > 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 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061206/c4087369/attachment.htm From nytrokiss at gmail.com Thu Dec 7 04:19:41 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 6 Dec 2006 19:19:41 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: <45749E62.7010204@probo.com> References: <4574960A.7030501@alum.rpi.edu> <45749E62.7010204@probo.com> Message-ID: <8a6b8e350612061919n2e9dc0c2r670e6711dd846ed0@mail.gmail.com> PYPY would help because it is said to compile python programs what i would also recommend is prex and pysco On 12/4/06, Tim Roberts wrote: > > Bob Gailer wrote: > >> So maybe try your Python suggestion, if I can get it to work. You > showed it > >> as Python being started first and then accessing Word, but I suppose > that > >> the other way that people suggested (use VB for dialog boxes, then > shell > >> Python) is OK, too. Can the parameters that were entered in the dialog > box > >> be made accessible to Python? > >> > > Shelling to Python is one method, but it is also possible to write a COM > server in Python and instantiate it from VB just like any COM object. > If you actually need to pass data back and forth, that may be a better > way. > > -- > 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 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061206/7557654a/attachment.html From nytrokiss at gmail.com Thu Dec 7 04:21:29 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 6 Dec 2006 19:21:29 -0800 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() In-Reply-To: <45776831.4070709@probo.com> References: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> <45776831.4070709@probo.com> Message-ID: <8a6b8e350612061921w8c3c2e8v8eef5df1de85e9cc@mail.gmail.com> Can you just call a GUI api that interfaces directly with the graphics card? On 12/6/06, Tim Roberts wrote: > > Ray Schumacher wrote: > > I've been mulling screen capture code. I tried PIL's > > ImageGrab().grab() (with pymedia) but find PIL's method to be pretty > > slow, ~4grabs per second max with no other processes. > > pymedia is pretty quick once I hand it the data. > > > > How large is your screen? A 1600x1200 true-color desktop is 8 megabytes > worth of pixels, and it can take tens of milliseconds just to copy it > over the PCI bus to main memory. > > > There has to be another way to get a copy or buffer() of the screen > > DC's data that is faster (I hope). > > > > I putsed around with win32gui > > desktop = win32gui.GetDesktopWindow() > > dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) > > but couldn't see how to get at the data via the handle. > > > > You can use BitBlt to copy it to a DIB, but it's not going to be very > convenient to work with. > > -- > 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 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061206/90a1e1e8/attachment.htm From gagsl-p32 at yahoo.com.ar Thu Dec 7 05:21:56 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 07 Dec 2006 01:21:56 -0300 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() In-Reply-To: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> References: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> Message-ID: <7.0.1.0.0.20061207011611.054325c0@yahoo.com.ar> At Wednesday 6/12/2006 21:32, Ray Schumacher wrote: >I've been mulling screen capture code. I tried PIL's >ImageGrab().grab() (with pymedia) but find PIL's method to be pretty >slow, ~4grabs per second max with no other processes. >pymedia is pretty quick once I hand it the data. > >There has to be another way to get a copy or buffer() of the screen >DC's data that is faster (I hope). Yes, but I doubt you can get faster without writting a specific program. - watch for invalidate and paint events so you just grab the screen areas that actually have changed. - use a "pseudo video card" driver to watch for drawing primitives as TightVNC does (or is it some other VNC clone?) -- Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From rays at blue-cove.com Thu Dec 7 07:01:10 2006 From: rays at blue-cove.com (RayS) Date: Wed, 06 Dec 2006 22:01:10 -0800 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() In-Reply-To: <45776831.4070709@probo.com> References: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> <45776831.4070709@probo.com> Message-ID: <6.2.3.4.2.20061206211504.033ea670@blue-cove.com> At 05:02 PM 12/6/2006, Tim Roberts wrote: >Ray Schumacher wrote: > > I've been mulling screen capture code. I tried PIL's > > ImageGrab().grab() (with pymedia) but find PIL's method to be pretty > > slow, ~4grabs per second max with no other processes. > > pymedia is pretty quick once I hand it the data. > >How large is your screen? A 1600x1200 true-color desktop is 8 megabytes >worth of pixels, and it can take tens of milliseconds just to copy it >over the PCI bus to main memory. 1024x768, and I want to immediately resize to 640x480 (or smaller) before handing off to pymedia for MPEG input. I have a PIL version that does ~3.2fps, and, the PIL method does not capture the mouse... Gabriel's suggestion of watching events for copying sub-areas is good... I can track the mouse using pyHook, I think. > > I putsed around with win32gui > > desktop = win32gui.GetDesktopWindow() > > dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) > > but couldn't see how to get at the data via the handle. > > > >You can use BitBlt to copy it to a DIB, but it's not going to be very >convenient to work with. I'll try it; all I want to do is downsample and send it off to pymedia as a string: vcodec.VFrame( PIX_FMT_RGB24, (640, 480), (s, None, None)) I had made a version of http://pymedia.org/tut/src/make_video.py.html >with PIL ImageGrab().grab() as the string source, profiled, and saw >that it was the PIL method as 80+% of the time. Thanks all, Ray From theller at ctypes.org Thu Dec 7 15:09:29 2006 From: theller at ctypes.org (Thomas Heller) Date: Thu, 07 Dec 2006 15:09:29 +0100 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks In-Reply-To: <2d8e22aa0612061406i7aa2d89cq2cedef71750ee214@mail.gmail.com> References: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> <2d8e22aa0612061406i7aa2d89cq2cedef71750ee214@mail.gmail.com> Message-ID: johnny loops schrieb: > Thanks, these references are really helpful, and I think I understand > a lot more of the path using comtypes. Continuing with my pseudo code > example-- this is what I think I should do: > > -run GetModule() on the library, which should create the interface foo Yes. > -Create a class implementing foo Yes. > -Create object implementing interface foo Yes. > -Pass the object to the other com function that will fire callbacks to it > > comtypes.client.GetModule('CLSID that contains foo') > class myComObjClass(COMObject): > _com_interfaces_ = [foo] > > def foo_OnFunc1(self, this, variable1): > do some stuff on callback > def foo_OnFunc2(self, this, variable2): > do some other stuff > > o=myComObjClass() > otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) > > What I'm not sure about is the step that creates the object. Before, > when I tried using win32com, I thought I had to wrap a server to pass > it-- this didn't work, so I could have been off the mark here. Does > this look right? Is it really this easy? Yes, it should work this way. The COMObject base class takes care of the rest. Thomas From theller at ctypes.org Thu Dec 7 16:16:23 2006 From: theller at ctypes.org (Thomas Heller) Date: Thu, 07 Dec 2006 16:16:23 +0100 Subject: [python-win32] comtypes Message-ID: <45783047.1090400@ctypes.org> comtypes seems to gain some attention (comtypes is a pure Python, lightweight COM client and server framework, based on the ctypes Python FFI package.) I'll try to release a new version over the next days. However, I'm wondering what would be the correct list to discuss this package... - the python-win32 mailing list - the ctypes-users mailing list - or should I create a new comtypes-users mailing list, mirrored on gmane, of course? Thanks for any opinions, Thomas From todd at ccb.wustl.edu Thu Dec 7 16:27:51 2006 From: todd at ccb.wustl.edu (Todd Dolinsky) Date: Thu, 7 Dec 2006 10:27:51 -0500 Subject: [python-win32] Obtaining LSA functions via Python 1.5.2 Message-ID: <97ee2dff0612070727x7fe8744ay950d1d1f364b6dba@mail.gmail.com> Hi everyone - I'd like to write a script that can return a list of users/groups that have a given privilege. After researching a bit I found the win32security.Lsa* functions from the newest Python 2.* releases to be exactly what I'm looking for. The problem is that the application I am writing for requires Python 1.5.2, and I can't seem to compile a working version using this older version of Python. Has anyone been able to access the LSA functions in Python 1.5.2? I don't need to use one of the most recent builds per-se, just one that has the above functions. Thanks for your help. Todd From huaxing.wu at guidant.com Thu Dec 7 17:28:02 2006 From: huaxing.wu at guidant.com (Wu, Huaxing (STP)) Date: Thu, 7 Dec 2006 10:28:02 -0600 Subject: [python-win32] Question about os.system In-Reply-To: <8a6b8e350612061907k5e02490ck769c26d7a45e96f8@mail.gmail.com> Message-ID: <6815D9842896894F9CE2C9D3B19BCA0F91738E@STPEVS03.stp.guidant.com> Thanks for trying out and fix the typo (Outlook loves to capitalize the first letter) My environment is Windows 2000, and I was running from Eclipse. To follow your example, I tried to run them from command prompt, and I got C:\temp\x>aa.py in C:\temp\x\aa.py in C:\temp\x\bb.py in C:\temp\x\cc.py executingh cc.py 0 executingh bb.py 0 So it works. But when I tried again to run them from eclipse. I got only in C:\temp\x\aa.py in C:\temp\x\bb.py executingh cc.py 0 executingh bb.py 0 The "in C:\temp\x\cc.py" never get printed And some of my more complicated real example shows cc.py never run. Will this be a problem with Pydev? Thank you ________________________________ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of James Matthews Sent: Wednesday, December 06, 2006 9:08 PM To: Tim Roberts Cc: Python-Win32 List Subject: Re: [python-win32] Question about os.system Try Exec with the file handle On 12/6/06, Tim Roberts wrote: Wu, Huaxing (STP) wrote: > > Hi, all, > > I have some problem using os.system when a command that spawned by > os.system itself tries to use os.system. It may be easier to explain > with an example. > > Assume I have 3 python scripts. They are aa.py, bb.py and cc.py. > File aa.py (Try to run bb.py using os.system) > import os > print "in", __file__ > sysCode = os.system(" bb.py") > Print "executing bb.py ", sysCode > > File bb.py (try to run cc.py using os.system) > import os > print "in", __file__ > sysCode = os.system("cc.py ") > Print "executing cc.py ", sysCode > > File cc.py > import os > print "in", __file__ > > On command line, run "aa.py" > > And cc.py never get run. Is there anything wrong in the code? > Works for me in Windows XP, once I fixed your print/Print confusion. What environment are you in? C:\tmp\x>type aa.py import os print "in", __file__ sysCode = os.system("bb.py") print "executing bb.py ", sysCode C:\tmp\x>type bb.py import os print "in", __file__ sysCode = os.system("cc.py") print "executing cc.py ", sysCode C:\tmp\x>type cc.py import os print "in", __file__ C:\tmp\x>python aa.py in aa.py in C:\tmp\x\bb.py in C:\tmp\x\cc.py executing cc.py 0 executing bb.py 0 C:\tmp\x> -- 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 -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061207/34cb3e8a/attachment.html From timr at probo.com Thu Dec 7 18:24:29 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 07 Dec 2006 09:24:29 -0800 Subject: [python-win32] Question about os.system In-Reply-To: <8a6b8e350612061907k5e02490ck769c26d7a45e96f8@mail.gmail.com> References: <6815D9842896894F9CE2C9D3B19BCA0F917387@STPEVS03.stp.guidant.com> <4577676B.3090908@probo.com> <8a6b8e350612061907k5e02490ck769c26d7a45e96f8@mail.gmail.com> Message-ID: <45784E4D.9030705@probo.com> James Matthews wrote: > Try Exec with the file handle The problem with that suggestion is that "exec" executes the new script in the same process, using the same namespaces. In that case, you might as well use "import". I'm assuming the OP had some reason for wanting to spawn separate processes. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Dec 7 18:26:11 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 07 Dec 2006 09:26:11 -0800 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() In-Reply-To: <8a6b8e350612061921w8c3c2e8v8eef5df1de85e9cc@mail.gmail.com> References: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> <45776831.4070709@probo.com> <8a6b8e350612061921w8c3c2e8v8eef5df1de85e9cc@mail.gmail.com> Message-ID: <45784EB3.9030305@probo.com> James Matthews wrote: > Can you just call a GUI api that interfaces directly with the graphics > card? That's exactly what BitBlt is. The simple fact is that desktop images these days are HUGE. The device-to-memory path is not the most optimized path in a graphics chip. It just takes time to snapshot the screen. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Dec 7 18:31:47 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 07 Dec 2006 09:31:47 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: <8a6b8e350612061919n2e9dc0c2r670e6711dd846ed0@mail.gmail.com> References: <4574960A.7030501@alum.rpi.edu> <45749E62.7010204@probo.com> <8a6b8e350612061919n2e9dc0c2r670e6711dd846ed0@mail.gmail.com> Message-ID: <45785003.8020804@probo.com> James Matthews wrote: > PYPY would help because it is said to compile python programs what i > would also recommend is prex and pysco Your suggestions are all about deployment and optimization. They don't particularly address the OP's problem. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Dec 7 20:20:06 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 07 Dec 2006 11:20:06 -0800 Subject: [python-win32] Question about os.system In-Reply-To: <6815D9842896894F9CE2C9D3B19BCA0F91738E@STPEVS03.stp.guidant.com> References: <6815D9842896894F9CE2C9D3B19BCA0F91738E@STPEVS03.stp.guidant.com> Message-ID: <45786966.4040702@probo.com> Wu, Huaxing (STP) wrote: > Thanks for trying out and fix the typo (Outlook loves to capitalize > the first letter) > > My environment is Windows 2000, and I was running from Eclipse. > To follow your example, I tried to run them from command prompt, and I got > C:\temp\x>aa.py > in C:\temp\x\aa.py > in C:\temp\x\bb.py > in C:\temp\x\cc.py > executingh cc.py 0 > executingh bb.py 0 > > So it works. > > But when I tried again to run them from eclipse. I got only > in C:\temp\x\aa.py > in C:\temp\x\bb.py > executingh cc.py 0 > executingh bb.py 0 > > The "in C:\temp\x\cc.py" never get printed And some of my more > complicated real example shows cc.py never run. The evidence suggests that cc.py DID run (in that os.system returned 0), but that its output went somewhere else. Perhaps Eclipse is mixing up the standard handles in some way. Have you tried doing this with the subprocess module? It slightly less convenient than os.system, but you get a lot more control. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rays at blue-cove.com Fri Dec 8 02:05:31 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Thu, 07 Dec 2006 17:05:31 -0800 Subject: [python-win32] screen capture and win32gui.GetDesktopWindow() In-Reply-To: <45776831.4070709@probo.com> References: <6.2.3.4.2.20061206150405.05c4fdf8@blue-cove.com> <45776831.4070709@probo.com> Message-ID: <6.2.3.4.2.20061207162625.05c74780@blue-cove.com> Upon further tries, I can get handles, DCs, and/or Win32 BMPs from the desktop, but I can't get to a DIB from there. Can someone outline the general process that might be required? Ie., get window handle create in/out DCs select bmp to outDC blit inDC data I tried emulating a nice IronPython example: http://www.voidspace.org.uk/python/weblog/arch_d7_2006_10_28.shtml but, hdcSrc = win32gui.GetWindowDC(win32gui.GetDesktopWindow()) hdcDestH = win32ui.CreateDCFromHandle(win32gui.GetDesktopWindow() hdcDest = win32gui.CreateCompatibleDC(hdcSrc) hBitmap = win32gui.CreateCompatibleBitmap(hdcSrc, 1024, 768) win32gui.SelectObject(hdcDest, hBitmap) hdcDestH.BitBlt((0, 0), (1024, 768), hdcSrc, (0, 0), 0x00CC0020) fails with "TypeError: The 'O' param must be a PyCDC object". So, how to make the DCs cooperate? myHdc = win32gui.GetDC(dtwnd) win_sz = win32gui.GetClientRect(dtwnd) myDC = win32ui.CreateDC() myMemDC = myDC.CreateCompatibleDC(myHdc) fails with "TypeError: argument number 1: object is not a PyCDC" I need a DIB, I think, (or anything that can be used with pymedia). I started working on a ctypes version: CreateDIBitmap = windll.GDI32.CreateDIBitmap etc., but that will take me some time, I think, and I'm not sure if it's the correct procedure anyway. Thanks, more tries tomorrow. Ray At 05:02 PM 12/6/2006, Tim Roberts wrote: Ray Schumacher wrote: > I've been mulling screen capture code. I tried PIL's > ImageGrab().grab() (with pymedia) but find PIL's method to be pretty > slow, ~4grabs per second max with no other processes. > pymedia is pretty quick once I hand it the data. > How large is your screen? A 1600x1200 true-color desktop is 8 megabytes worth of pixels, and it can take tens of milliseconds just to copy it over the PCI bus to main memory. > There has to be another way to get a copy or buffer() of the screen > DC's data that is faster (I hope). > > I putsed around with win32gui > desktop = win32gui.GetDesktopWindow() > dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) > but couldn't see how to get at the data via the handle. > You can use BitBlt to copy it to a DIB, but it's not going to be very convenient to work with. -- 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 michielv at michielvleugel.com Tue Dec 5 17:15:20 2006 From: michielv at michielvleugel.com (Michiel Vleugel) Date: Tue, 05 Dec 2006 17:15:20 +0100 Subject: [python-win32] How to take a snapshot of a specific control? Message-ID: <45759B18.9030201@michielvleugel.com> Hello list, I'm trying to come up with a script that will take a screenshot of internet exploder, (for IE automated unittest script for web development) but having trouble drilling fown to the dc of the control. It looks like I the control that is needed is called "Internet Explorer_Server" inside the IE application. How can I get the dc of this control? I tried getting it by using GetDC() on the control, but it doesnt seem to work (cause that only works on windows, not on controls). Any help is greatly appreciated! Michael Vleugel From rays at blue-cove.com Fri Dec 8 03:45:37 2006 From: rays at blue-cove.com (RayS) Date: Thu, 07 Dec 2006 18:45:37 -0800 Subject: [python-win32] How to take a snapshot of a specific control? In-Reply-To: <45759B18.9030201@michielvleugel.com> References: <45759B18.9030201@michielvleugel.com> Message-ID: <6.2.3.4.2.20061207184411.033e2d60@blue-cove.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061207/cc3ece68/attachment.htm From rwupole at msn.com Fri Dec 8 04:11:18 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 7 Dec 2006 22:11:18 -0500 Subject: [python-win32] Re: screen capture and win32gui.GetDesktopWindow() Message-ID: Ray Schumacher wrote: > Upon further tries, I can get handles, DCs, and/or Win32 BMPs from > the desktop, but I can't get to a DIB from there. > > Can someone outline the general process that might be required? > Ie., > get window handle > create in/out DCs > select bmp to outDC > blit inDC data > print_desktop.py in the demos folder does a screen capture for printing, but you should be able to adapt it. Roger From rwupole at msn.com Fri Dec 8 04:49:36 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 7 Dec 2006 22:49:36 -0500 Subject: [python-win32] Re: Obtaining LSA functions via Python 1.5.2 Message-ID: Todd Dolinsky wrote: > Hi everyone - > > I'd like to write a script that can return a list of users/groups that > have a given privilege. After researching a bit I found the > win32security.Lsa* functions from the newest Python 2.* releases to be > exactly what I'm looking for. The problem is that the application I > am writing for requires Python 1.5.2, and I can't seem to compile a > working version using this older version of Python. > > Has anyone been able to access the LSA functions in Python 1.5.2? I > don't need to use one of the most recent builds per-se, just one that > has the above functions. > > Thanks for your help. > > Todd It should be possible to backport these functions, but it would take some research into whether their current implementation uses any features added since 1.5.2. You could start with source for the last build issued for 1.52 and try copying just the functions you need into win32security.i. However, right now the older builds on Mark's Starship page aren't available since the starship site had some major problems. Roger From johnnyloops at gmail.com Fri Dec 8 06:41:56 2006 From: johnnyloops at gmail.com (johnny loops) Date: Thu, 7 Dec 2006 21:41:56 -0800 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks In-Reply-To: References: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> <2d8e22aa0612061406i7aa2d89cq2cedef71750ee214@mail.gmail.com> Message-ID: <2d8e22aa0612072141q40a94c04x5374c047235b2ef0@mail.gmail.com> Thomas, thanks for your help. Everything seemed to work except when I needed to pass my com object to another com function to receive callbacks > > o=myComObjClass() > > otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) The other dispatched com object was created using win32com, and other functions of it work fine. However, this specific function needs to be called with a com object implementing the interface as one of the inputs, and then its functions will be called as callbacks. The error I get when I pass o to this function is ValueError: argument is not a COM object Do you have any suggestions? Thanks again for your help On 12/7/06, Thomas Heller wrote: > johnny loops schrieb: > > Thanks, these references are really helpful, and I think I understand > > a lot more of the path using comtypes. Continuing with my pseudo code > > example-- this is what I think I should do: > > > > -run GetModule() on the library, which should create the interface foo > > Yes. > > > -Create a class implementing foo > > Yes. > > > -Create object implementing interface foo > > Yes. > > > -Pass the object to the other com function that will fire callbacks to it > > > > comtypes.client.GetModule('CLSID that contains foo') > > class myComObjClass(COMObject): > > _com_interfaces_ = [foo] > > > > def foo_OnFunc1(self, this, variable1): > > do some stuff on callback > > def foo_OnFunc2(self, this, variable2): > > do some other stuff > > > > o=myComObjClass() > > otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) > > > > What I'm not sure about is the step that creates the object. Before, > > when I tried using win32com, I thought I had to wrap a server to pass > > it-- this didn't work, so I could have been off the mark here. Does > > this look right? Is it really this easy? > > Yes, it should work this way. The COMObject base class takes care of the rest. > > Thomas > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From theller at ctypes.org Fri Dec 8 10:19:14 2006 From: theller at ctypes.org (Thomas Heller) Date: Fri, 08 Dec 2006 10:19:14 +0100 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks In-Reply-To: <2d8e22aa0612072141q40a94c04x5374c047235b2ef0@mail.gmail.com> References: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> <2d8e22aa0612061406i7aa2d89cq2cedef71750ee214@mail.gmail.com> <2d8e22aa0612072141q40a94c04x5374c047235b2ef0@mail.gmail.com> Message-ID: johnny loops schrieb: > Thomas, thanks for your help. Everything seemed to work except when I > needed to pass my com object to another com function to receive > callbacks > >> > o=myComObjClass() >> > otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) > > The other dispatched com object was created using win32com, and other > functions of it work fine. However, this specific function needs to > be called with a com object implementing the interface as one of the > inputs, and then its functions will be called as callbacks. The error > I get when I pass o to this function is > > ValueError: argument is not a COM object > > Do you have any suggestions? Thanks again for your help If I understand you correctly, you have created the otherDispatchedComObject by calling some win32com functions, and you want to pass a comtypes object to a method of otherDispatchedComObject? If this is so, then it fails because win32com does not know anything about comtypes. Fortunately, pythoncom25.dll exposes a function that can be called with ctypes to do the conversion. I have attached a module containing a unittest that does this. The 'comtypes2pywin' function accepts a comtypes COM pointer or a comtypes COMObject instance and returns a win32com object - a object, or a object. I think that should do what you want - please report back. This code should probably go into comtypes somewhere. Thomas -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: test_win32com_interop.py Url: http://mail.python.org/pipermail/python-win32/attachments/20061208/ba2a68b3/attachment.asc From johnnyloops at gmail.com Sun Dec 10 00:08:43 2006 From: johnnyloops at gmail.com (johnny loops) Date: Sat, 9 Dec 2006 15:08:43 -0800 Subject: [python-win32] Implementing custom com interface, passing it to another com object for callbacks In-Reply-To: References: <2d8e22aa0612061017y1d8f6fe4x9c2861127b812d6c@mail.gmail.com> <2d8e22aa0612061406i7aa2d89cq2cedef71750ee214@mail.gmail.com> <2d8e22aa0612072141q40a94c04x5374c047235b2ef0@mail.gmail.com> Message-ID: <2d8e22aa0612091508m6dc57eccpc08718a3139b8d9@mail.gmail.com> Thomas, That did it! Thank you very much for your help. Calling the comtypes2pywin function on the object worked. After that, I created the com object 'otherDispatchedComObject' using comtypes and that also worked. Again, thanks for your help! On 12/8/06, Thomas Heller wrote: > johnny loops schrieb: > > Thomas, thanks for your help. Everything seemed to work except when I > > needed to pass my com object to another com function to receive > > callbacks > > > >> > o=myComObjClass() > >> > otherDispatchedComObject.FunctionThatNeedsInterface(o, otherInputs) > > > > The other dispatched com object was created using win32com, and other > > functions of it work fine. However, this specific function needs to > > be called with a com object implementing the interface as one of the > > inputs, and then its functions will be called as callbacks. The error > > I get when I pass o to this function is > > > > ValueError: argument is not a COM object > > > > Do you have any suggestions? Thanks again for your help > > If I understand you correctly, you have created the otherDispatchedComObject > by calling some win32com functions, and you want to pass a comtypes object > to a method of otherDispatchedComObject? > > If this is so, then it fails because win32com does not know anything about > comtypes. Fortunately, pythoncom25.dll exposes a function that can be called > with ctypes to do the conversion. I have attached a module containing a unittest > that does this. The 'comtypes2pywin' function accepts a comtypes COM pointer > or a comtypes COMObject instance and returns a win32com object - a > object, or a object. > > I think that should do what you want - please report back. This code should probably > go into comtypes somewhere. > > Thomas From mhammond at skippinet.com.au Mon Dec 11 05:06:25 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 11 Dec 2006 15:06:25 +1100 Subject: [python-win32] How to take a snapshot of a specific control? In-Reply-To: <6.2.3.4.2.20061207184411.033e2d60@blue-cove.com> Message-ID: <21a501c71cd9$bab6c690$110a0a0a@enfoldsystems.local> RayS wrote: > I'm trying to do a fast desktop capture myself, and having DC/pyDC > confusion. I'm not sure exactly what this means, but I'm guessing you are having trouble with the pythonwin/win32ui GetSafeHdc objects, versus those used by win32gui. The short story is that unless you really need to (or otherwise need MFC functionality), you should stick to win32gui functions. You should let me know if win32ui has features lacking in win32gui that you need. If you are stuck using PyCDC objects, you can get the integer handle by calling the GetSafeHdc() function, which is then suitable for use with win32gui - win32gui uses integers for most handles, but that also means you are responsible for managing their lifetime correctly. HTH, Mark From mhammond at skippinet.com.au Mon Dec 11 05:11:40 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 11 Dec 2006 15:11:40 +1100 Subject: [python-win32] comtypes In-Reply-To: <45783047.1090400@ctypes.org> Message-ID: <21a601c71cda$77045790$110a0a0a@enfoldsystems.local> Thomas wrote: > comtypes seems to gain some attention (comtypes is a pure > Python, lightweight > COM client and server framework, based on the ctypes Python > FFI package.) > > I'll try to release a new version over the next days. > > However, I'm wondering what would be the correct list to > discuss this package... > > - the python-win32 mailing list > > - the ctypes-users mailing list > > - or should I create a new comtypes-users mailing list, > mirrored on gmane, of course? I personally think the current comtypes related traffic is not yet a burden, so I've no problem with discussions happening here. Once traffic picks up though it probably will make sense for its own list. I don't feel too strongly about it though, so if other people have stronger opinions I'm sure I would remain happy :) Cheers, Mark From maria.reinhammar at accalon.com Mon Dec 11 12:57:14 2006 From: maria.reinhammar at accalon.com (Reinhammar Maria) Date: Mon, 11 Dec 2006 12:57:14 +0100 Subject: [python-win32] Using Solid Edge from Python via COM Message-ID: Hi folks! This is very Solid Edge-oriented but I found some entries on this list during a web-search recently. We wish to use Python as language/environment for creation of automation processes w.r.t. our CAD. So far I have successfully used makepy to create the Python interfaces from the type libs and I have also been able to access and manipulate Assemblies and Parts. However, I have problems with * accessing some details like Sketch and Patterns * understanding how to map the GUI actions to programmatic statements, e.g. mating surfaces * understanding the Solid Edge way of object modelling (data that intuitively should be found together are somewhat dispersed) * setting names on objects from the GUI to be used from the program I seek your advice and experience! Big Thanks in advance// Maria Reinhammar Software Engineer Accalon AB ************************************************************************ ************************ CONFIDENTIALITY AND DISCLAIMER This e-mail and its attachments are intended for the above named addressee(s) only and may be confidential. If the mail has come to you in error please reply to this e-mail and highlight the error. In addition, we kindly ask you to destroy the Mail. Please be aware that we disclaim all liability for the integrity or for the accuracy of this Mail, as transmissions via Internet are not error free communications medium. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061211/02a8bcfd/attachment.htm From rays at blue-cove.com Mon Dec 11 20:02:01 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Mon, 11 Dec 2006 11:02:01 -0800 Subject: [python-win32] How to take a snapshot of a specific control? In-Reply-To: <21a501c71cd9$bab6c690$110a0a0a@enfoldsystems.local> References: <6.2.3.4.2.20061207184411.033e2d60@blue-cove.com> <21a501c71cd9$bab6c690$110a0a0a@enfoldsystems.local> Message-ID: <6.2.3.4.2.20061211101504.05c46e08@blue-cove.com> Thanks for the reply, At 08:06 PM 12/10/2006, Mark Hammond wrote: > I'm trying to do a fast desktop capture myself, and having DC/pyDC > confusion. I'm not sure exactly what this means, but I'm guessing you are having trouble with the pythonwin/win32ui GetSafeHdc objects, versus those used by win32gui. I'm generally confused by DC/pyDC, PyCDC, selecting and blitting.. The goal is to get a 640x480 RGB image data string from the screen window that I can pass to pyMedia. I've tried various permutations of the below lines, but I realize that I really don't get the Windows DC/BMP/blit concepts: the order that windows-handles-DCs-blits-selects-BMPs need to be created. These lines all execute: dtwnd = win32gui.GetDesktopWindow() hdcSrc = win32gui.GetWindowDC(dtwnd) hdcDestH = win32ui.CreateDCFromHandle(dtwnd) hdcDest = win32gui.CreateCompatibleDC(hdcSrc) hBitmap = win32gui.CreateCompatibleBitmap(hdcSrc, 1024, 768) win32gui.SelectObject(hdcDest, hBitmap) destHDC = hdcDestH.GetSafeHdc() but I start having trouble with hdcDestH.BitBlt((0, 0), (1024, 768), hdcSrc, (0, 0), 0x00CC0020) TypeError: The 'O' param must be a PyCDC object and on from there. I can't say that I need anything from win32ui, since I don't know what I need at all! Thank you, Ray From mhammond at skippinet.com.au Mon Dec 11 23:53:37 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 12 Dec 2006 09:53:37 +1100 Subject: [python-win32] How to take a snapshot of a specific control? In-Reply-To: <6.2.3.4.2.20061211101504.05c46e08@blue-cove.com> Message-ID: <245401c71d77$323e35c0$110a0a0a@enfoldsystems.local> > These lines all execute: > dtwnd = win32gui.GetDesktopWindow() > hdcSrc = win32gui.GetWindowDC(dtwnd) > hdcDestH = win32ui.CreateDCFromHandle(dtwnd) The last line above is a problem - try something like hdcDestH = win32gui.GetDC(dtwnd) > hdcDest = win32gui.CreateCompatibleDC(hdcSrc) > hBitmap = win32gui.CreateCompatibleBitmap(hdcSrc, 1024, 768) > win32gui.SelectObject(hdcDest, hBitmap) > destHDC = hdcDestH.GetSafeHdc() > > but I start having trouble with > hdcDestH.BitBlt((0, 0), (1024, 768), hdcSrc, (0, 0), 0x00CC0020) > TypeError: The 'O' param must be a PyCDC object > and on from there. Then you want something like win32gui.BitBlt(hdcDestH, (0,0), ...) > I can't say that I need anything from win32ui, since I don't know > what I need at all! In the above, you are using win32ui.CreateDCFromHandle() - and given what I said in the last mail, you probably want to try and find win32gui operations instead of win32ui ones Mark From rays at blue-cove.com Tue Dec 12 01:35:24 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Mon, 11 Dec 2006 16:35:24 -0800 Subject: [python-win32] How to take a snapshot of a specific control? In-Reply-To: <245401c71d77$323e35c0$110a0a0a@enfoldsystems.local> References: <6.2.3.4.2.20061211101504.05c46e08@blue-cove.com> <245401c71d77$323e35c0$110a0a0a@enfoldsystems.local> Message-ID: <6.2.3.4.2.20061211153823.05c68a88@blue-cove.com> At 02:53 PM 12/11/2006, Mark Hammond wrote: > These lines all execute: > dtwnd = win32gui.GetDesktopWindow() > hdcSrc = win32gui.GetWindowDC(dtwnd) > hdcDestH = win32ui.CreateDCFromHandle(dtwnd) The last line above is a problem - try something like hdcDestH = win32gui.GetDC(dtwnd) > hdcDest = win32gui.CreateCompatibleDC(hdcSrc) > hBitmap = win32gui.CreateCompatibleBitmap(hdcSrc, 1024, 768) > win32gui.SelectObject(hdcDest, hBitmap) > destHDC = hdcDestH.GetSafeHdc() > > but I start having trouble with > hdcDestH.BitBlt((0, 0), (1024, 768), hdcSrc, (0, 0), 0x00CC0020) > TypeError: The 'O' param must be a PyCDC object > and on from there. Then you want something like win32gui.BitBlt(hdcDestH, (0,0), ...) I did a dir(win32gui) and BitBlt was not there! i had tried before, and so was mystified - I had ActivePython 2.4.1 Build 245, and just upgraded to 2.4.3, and now have BitBlt() I found some code at http://trac.browsershots.org/browser/trunk/shotfactory/lib/gui/windows.py?rev=585 import win32gui import win32con from time import time as t t0=t() hDC = win32gui.GetWindowDC(0) memDC = win32gui.CreateCompatibleDC(hDC) memBM = win32gui.CreateCompatibleBitmap(hDC, 1024, 768) win32gui.SelectObject(memDC, memBM) win32gui.BitBlt(memDC, 0, 0, 1024, 768, hDC, 0, 0, win32con.SRCCOPY) t()-t0 But, the timer gives .57seconds ! even slower than PIL's ImageGrab Module :-( win32gui.StretchBlt(memDC, 0, 0, 1024, 768, hDC, 0, 0, 640, 480, win32con.SRCCOPY) is .25 seconds, a bit better. Whole screen caps do seem a bit slow, so it looks like StretchBlt on subregions that are modified are required. It doesn't look like it can be done quickly, without the VNC dependant py packages or the Media 9 Screen codec > I can't say that I need anything from win32ui, since I don't know > what I need at all! In the above, you are using win32ui.CreateDCFromHandle() - and given what I said in the last mail, you probably want to try and find win32gui operations instead of win32ui ones I was trying the kitchen sink... Best, and thanks for the help, Ray From Ola.Rylow at hiq.se Tue Dec 12 09:17:15 2006 From: Ola.Rylow at hiq.se (Ola Rylow) Date: Tue, 12 Dec 2006 09:17:15 +0100 Subject: [python-win32] Problem with multiple calls of a DLL Message-ID: <4336B5C3DC33A74FA393F4F88152F4EC5DA1AE@hiqqbexc001.sto.hiq.se> Hi, I know this is not exactly a new question on this list but I have not been able to solve my problems by reading old threads. I have a dll (MyDLL) from which I want to call some methods. I've tried using Ctypes: print windll.MyDLL.FirstMethod() print windll.MyDLL.SecondMethod() If I run this, SecondMethod fails, but if I switch order FirstMethod will fail instead (since it is the second called...). The same dll can be used without problems in C++ code. So my questions are: 1. Does Ctypes have any "FreeLibrary" function? 2. Have you got any suggestions on alternative ways to call a dll (assuming you haven't got the source code to the dll)? Regards Ola -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061212/1e202bc4/attachment.htm From benn at cenix-bioscience.com Tue Dec 12 10:44:06 2006 From: benn at cenix-bioscience.com (Neil Benn) Date: Tue, 12 Dec 2006 10:44:06 +0100 Subject: [python-win32] Register COM Server for all users Message-ID: <457E79E6.2050108@cenix-bioscience.com> Hello, I'm doing some work on a simple Python COM server to wrap a SOAP client on a machine. It is going well and I have it working however when I attempt to register the python COM servers they are only registered in the current user namespace and not the all users namespace (HKEY_LOCAL_MACHINE). I've been looking through the docs and google searched and looked through the Python/win32 book and cannot find anything such as a command line switch to help me. Does anybody know how to install the PythonCOM server for all users - I am admin when registering the PythonCOM server. Thanks, in advance for your help. Cheers, Neil -- Neil Benn MSc Head of Automation Cenix BioScience GmbH Tatzberg 47 01307 Dresden Germany http://www.cenix-bioscience.com From fuzzyman at voidspace.org.uk Tue Dec 12 12:45:06 2006 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 12 Dec 2006 11:45:06 +0000 Subject: [python-win32] Python for System Administration Message-ID: <457E9642.8060407@voidspace.org.uk> Hello all, Sorry for the intrusion. I'm working on a book proposal about IronPython, with Manning. One of the chapters will be about Windows System Administration with Python, and will probably include some sections about Powershell. It will show how to use the Powershell libraries from IronPython and writing Powershell cmdlets with IronPython. I'd like to also include some sections about 'general' system administration tasks (on windows computers and networks) that can be achieved with Python. I'd very much like to hear from anyone who uses Python for sys-admin tasks. I'd like to know the sort of tasks you use Python for, and if possible see some examples that I can translate into IronPython code. Feel free to reply on list or privately email me. Thank you for your indulgence. ;-) Michael http://www.voidspace.org.uk/python/index.shtml -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.16/582 - Release Date: 11/12/2006 From mhammond at skippinet.com.au Tue Dec 12 13:04:53 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 12 Dec 2006 23:04:53 +1100 Subject: [python-win32] Register COM Server for all users In-Reply-To: <457E79E6.2050108@cenix-bioscience.com> Message-ID: <267501c71de5$bbf0df70$110a0a0a@enfoldsystems.local> > I'm doing some work on a simple Python COM server to wrap a > SOAP client on a machine. It is going well and I have it working > however when I attempt to register the python COM servers > they are only > registered in the current user namespace and not the all > users namespace > (HKEY_LOCAL_MACHINE). I've been looking through the docs and google > searched and looked through the Python/win32 book and cannot find > anything such as a command line switch to help me. > > Does anybody know how to install the PythonCOM server for > all users > - I am admin when registering the PythonCOM server. pywin32 will register a server under HKEY_CLASSES_ROOT which should be shared for all users - see http://msdn2.microsoft.com/en-gb/library/ms724475.aspx. Mark From Tim.Golden at viacom-outdoor.co.uk Tue Dec 12 14:05:56 2006 From: Tim.Golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 12 Dec 2006 13:05:56 -0000 Subject: [python-win32] Python for System Administration In-Reply-To: <457E9642.8060407@voidspace.org.uk> Message-ID: [Michael Foord] | Sorry for the intrusion. Not often we see you around these parts! | I'm working on a book proposal about IronPython, with Manning. Excellent news. | I'd like to also include some sections about 'general' system | administration tasks (on windows computers and networks) that can be | achieved with Python. Personally I'm delighted to see attention given to this subject in a book. (Or anywhere, for that matter). Altho' I'm not a sysadmin, I've spent a fair amount of time helping our sysadmins here and answering admin-y questions on the Python lists. I think Python's potential here -- especially under Windows -- is hugely underrated. Of course Powershell may sweep that potential away; who knows? Unsurprisingly perhaps, a lot of my recommendations involve WMI. Now I've no idea if WMI is still a concept under .NET or how it's invoked if it is. At present, you use the pywin32 GetObject method to invoke it. Is that still possible under IronPython? Or is there some -- possibly built-in -- equivalent? Anyway, examples of some of the vaguely sysadmin-y things I've either done myself or helped with. I suppose people's definition of sys-adminy varies a bit. I think I've been quite generous here; some of the examples are more development-y than admin-y. + Copy details from Outlook Contacts to Active Directory fields + Run through an Exchange mailbox pulling out large attachments and replacing them with a link to the same file on some NAS. + (subsequent to previous job) Rip through a network drive finding (large) duplicate files and replacing them with links or stubs. We had intended to use Junction Points for this one but our understanding of them was vague at the time (and isn't much better now, I think) so we didn't. + Watch our two Citrix servers for the occasional rogue process which would take one CPU up to 100% until it was killed. (This was a WMI one). + Monitor hard disks which were approaching capacity. (This was WMI too). This was only a short-term measure as our IT Director was happy to throw money at hardware, in this case, extra disks. + Monitor the call queue on our helpdesk database and alert techs/managers when new/updated calls come in. This one's been running for about three years now. (Not without a restart). + For the same system, use CherryPy to generate a simple webpage version of the call queue and call details. + Lots of bits and pieces in AD, eg making department names align with a list from HR, making capitalisation consistent, bulk uploads etc. + Semi-automatic signature generation for Outlook with optional image and link. This is just about to be replaced now by some bought-in solution which is a bit more automatic, sitting on the Exchange server itself and hooking in after the user's sent an email. My version just allowed the IT/Marketing teams to generate an email shortcut to a Python script which would generate the signature file and set it as the user's default. + Rip through a Linux image store accessed principally by Macs using Samba (cross-system or what?!) converting filenames which differed only by case into some other system. + Find home directories belonging to users who no longer existed or whose accounts were disabled. + Finding Outlook Contacts without a company photo. + Generating a contacts page for the company intranet showing details from Outlook plus a portrait where available. (For the record, this one used -- and still uses -- Xitami's LRWP mechanism). This one's been running for five years now and is easily the most used part of the Intranet. + Dump the company's entire Exchange GAL to some format (CSV, I think) for export to some other part of the company. + Add everyone in a CSV list to a particular NT group (this was before AD; using the win32net functions). + Various things with Subversion hooks / Trac and so on. + Determine which users were still running Win98 / some older OS. (This was a WMI special) + Remove / archive user files from a network drive which hadn't been accessed for at least 12 months and/or which belonged to a user whose account was disabled. I'm sure there were some other things ("Oh, Tim, could you just...?") but at least this gives you something of a flavour. I know that at least one user is using the WMI module to monitor the Win32 servers in his ISP because we worked together on performance improvements in the last release. Food for thought, I hope. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From fuzzyman at voidspace.org.uk Tue Dec 12 14:40:41 2006 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 12 Dec 2006 13:40:41 +0000 Subject: [python-win32] Python for System Administration In-Reply-To: References: Message-ID: <457EB159.9000703@voidspace.org.uk> Tim Golden wrote: > [Michael Foord] > > | Sorry for the intrusion. > > Not often we see you around these parts! > I'm one of those dodgy lurkers. :-) Most of my win32 experience is through IronPython, but there is a wealth of information on this list. > | I'm working on a book proposal about IronPython, with Manning. > > Excellent news. > It's not a done deal yet, but they want to publish the book and I'm working on the second cut of the proposal today. (The first proposal has already been out for review with some very positive responses.) With a bit of luck I'll be making an announcement on my blog soon. > | I'd like to also include some sections about 'general' system > | administration tasks (on windows computers and networks) that can be > | achieved with Python. > > Personally I'm delighted to see attention given to this > subject in a book. (Or anywhere, for that matter). Altho' > I'm not a sysadmin, I've spent a fair amount of time > helping our sysadmins here and answering admin-y questions > on the Python lists. I think Python's potential here -- > especially under Windows -- is hugely underrated. Of > course Powershell may sweep that potential away; who knows? > Despite the pain caused to me by sys-admins over the last few years I'm still keen to help them. :-) Powershell is a programming environment, but it doesn't scale well to full applications. As usual the clarity and simplicity of Python syntax mean that it is ideal for simple scripting tasks and scales well to large applications. In addition, most of Powershell functionality is implemented in a set of libraries which are fully accessible to IronPython. > Unsurprisingly perhaps, a lot of my recommendations > involve WMI. Now I've no idea if WMI is still a concept > under .NET or how it's invoked if it is. At present, > you use the pywin32 GetObject method to invoke it. > Is that still possible under IronPython? Or is there > some -- possibly built-in -- equivalent? > I've not used WMI before (although I've browsed your work before and *nearly* used it a few times). I assume they are in unmanaged code ? Using unmanaged code from IronPython is very easy, but requires a stub class in C#. This is because you need to use the 'DllImport' attribute and you can't use .NET attributes from IronPython. See the following for an example which uses GDI and User32 : http://www.voidspace.org.uk/python/weblog/arch_d7_2006_10_28.shtml#e530 > Anyway, examples of some of the vaguely sysadmin-y > things I've either done myself or helped with. I > suppose people's definition of sys-adminy varies a > bit. I think I've been quite generous here; some of > the examples are more development-y than admin-y. > [snip..] Thanks Tim, that's a *great* list. I'll look through it and maybe pull out a couple of examples. I'd love to discuss this with you. When I get to it I'll privately mail you. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.16/582 - Release Date: 11/12/2006 From simon.dahlbacka at gmail.com Tue Dec 12 15:12:27 2006 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Tue, 12 Dec 2006 16:12:27 +0200 Subject: [python-win32] Python for System Administration In-Reply-To: <457EB159.9000703@voidspace.org.uk> References: <457EB159.9000703@voidspace.org.uk> Message-ID: <57124720612120612n6b0ab50fhce95d9a2d3864262@mail.gmail.com> > > > > Unsurprisingly perhaps, a lot of my recommendations > > involve WMI. Now I've no idea if WMI is still a concept > > under .NET or how it's invoked if it is. At present, > > you use the pywin32 GetObject method to invoke it. > > Is that still possible under IronPython? Or is there > > some -- possibly built-in -- equivalent? > > > > I've not used WMI before (although I've browsed your work before and > *nearly* used it a few times). > > I assume they are in unmanaged code ? ..isn't the stuff in System.Management for WMI things, and thus probably the way to look into when wanting to use IronPython ? regards, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061212/4e44a230/attachment.htm From fuzzyman at voidspace.org.uk Tue Dec 12 15:20:28 2006 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 12 Dec 2006 14:20:28 +0000 Subject: [python-win32] Python for System Administration In-Reply-To: <57124720612120612n6b0ab50fhce95d9a2d3864262@mail.gmail.com> References: <457EB159.9000703@voidspace.org.uk> <57124720612120612n6b0ab50fhce95d9a2d3864262@mail.gmail.com> Message-ID: <457EBAAC.6020100@voidspace.org.uk> Simon Dahlbacka wrote: >> >> >> > Unsurprisingly perhaps, a lot of my recommendations >> > involve WMI. Now I've no idea if WMI is still a concept >> > under .NET or how it's invoked if it is. At present, >> > you use the pywin32 GetObject method to invoke it. >> > Is that still possible under IronPython? Or is there >> > some -- possibly built-in -- equivalent? >> > >> >> I've not used WMI before (although I've browsed your work before and >> *nearly* used it a few times). >> >> I assume they are in unmanaged code ? > > > > ..isn't the stuff in System.Management for WMI things, and thus probably > the > way to look into when wanting to use IronPython ? > http://msdn.microsoft.com/msdnmag/issues/02/05/WMIMan/ Looks like it. Thanks. I should be able to create/translate some good examples from here. Fuzzy > regards, > > Simon > > > ------------------------------------------------------------------------ > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.409 / Virus Database: 268.15.16/582 - Release Date: 11/12/2006 > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.16/582 - Release Date: 11/12/2006 From timr at probo.com Tue Dec 12 18:44:06 2006 From: timr at probo.com (Tim Roberts) Date: Tue, 12 Dec 2006 09:44:06 -0800 Subject: [python-win32] Problem with multiple calls of a DLL In-Reply-To: <4336B5C3DC33A74FA393F4F88152F4EC5DA1AE@hiqqbexc001.sto.hiq.se> References: <4336B5C3DC33A74FA393F4F88152F4EC5DA1AE@hiqqbexc001.sto.hiq.se> Message-ID: <457EEA66.5030503@probo.com> Ola Rylow wrote: > > I know this is not exactly a new question on this list but I have not > been able to solve my problems by reading old threads. > > I have a dll (MyDLL) from which I want to call some methods. I've > tried using Ctypes: > > print windll.MyDLL.FirstMethod() > print windll.MyDLL.SecondMethod() > > If I run this, SecondMethod fails, but if I switch order FirstMethod > will fail instead (since it is the second called...). > The same dll can be used without problems in C++ code. > So my questions are: > > 1. Does Ctypes have any "FreeLibrary" function? Are you saying your DLL *requires* that you unload the library between each call? That would be a grossly negligent design on the part of the DLL authors. Is it possible you simply have the calling sequence incorrect? Have you tried "cdll" instead of "windll"? How does it fail? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bokverket at hotmail.com Tue Dec 12 23:32:17 2006 From: bokverket at hotmail.com (Bokverket) Date: Tue, 12 Dec 2006 23:32:17 +0100 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin References: Message-ID: Tim and Michael, I am a Python neophyte and must admit that I am not familiar with all those Python library names that swish around this list. But that was not my point. The tasks on Michael's list that he has done/helped out with lately are to a large extent useful jobs that an ordinary user would love. Well, at least one who know how to program, iow use Python as _the_ scripting language to glue all these Micrsoft parts and apps together. This would require a wonderful Python-ish API on how to access for example Outlook Express address lists, Word and the file system. Plus some wonderful examples of useful examples and how to execute them in a Window environment.. IOW, making Python for Windows what AWK was for DOS :-) Does this library already exist, easy-to-use? Maybe this would be another book project for you?! All the best, G?ran, Stockholm, Sweden From Tim.Golden at viacom-outdoor.co.uk Wed Dec 13 14:15:09 2006 From: Tim.Golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 13 Dec 2006 13:15:09 -0000 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin In-Reply-To: Message-ID: [Bokverket] | The tasks on [Tim's] list that he has done/helped out with | lately are to a large extent useful jobs that an ordinary | user would love. Well, at least one who know how to program, | iow use Python as _the_ scripting language to glue all these | Micrsoft parts and apps together. | This would require a wonderful Python-ish API on how to | access for example Outlook Express address lists, Word | and the file system. Plus some wonderful examples of | useful examples and how to execute them in a Window | environment.. | IOW, making Python for Windows what AWK was for DOS :-) | | Does this library already exist, easy-to-use? [warning: bit of a ramble] I suppose the short answer to this is: no. Not least because the remit of any such library would be huge: Word, Outlook, Excel, Active Directory, WMI plus all sorts of file system and network bits and pieces. You'd probably spend months trying to formulate a unified API of some sort, only to discover that you'd re-implemented COM! That's not to dismiss your notion at all, just to give some kind of feeling of the enormity of the task. What complicates matters more (and I'm only brushing over the surface here) is the fact that several things are achievable via several different routes. WMI, for example, offers a consistent wrapper over a number of sys-adminy things but underneath it's calling the Win32 APIs. The advantage of using the WMI approach is that if you're using it for other things it's just more of the same. The disadvantage is that it's generally a bit slower and may not offer all the control which the direct API offers. Another issue I've found with several (abortive) modules to wrap CDO, NTFS Security, Active Directory etc. is that you find yourself reinventing the Microsoft API with no real benefit. Also, inevitably, the time taken to do it is always more than one first thought. Of course one answer here is: document rather than implement. ie rather than create some easy-to-use all-embracing Windows package, create some useful repository of Win32 admin code. This would also be great but again requires much more dedication of time than you might suppose. Existing possibilities include: + the Python Cookbook which contains a Win32 section + the (apparently defunct) win32com.de site + The effbot's faq win32 section + my own all-too-small set of how-tos + The archives of the Python, Python-win32 and Python-tutor lists + Loads of people's personal sites / blogs etc. Given the effort, one might use the python.org wiki to centralise things, but ISTM that this requires much more input of time than perhaps one realises. Certainly my heart's in it but realistically I know time is against me. My bread-and-butter comes from SQL development and while I try to use Python as much as I can, I'd be doing my employer a disservice if I were to spend more time on Python-related things that didn't benefit my company. What perhaps people don't realise is just how easy it is to code up a Python solution pretty much from scratch. Not infrequently when I answer a Win32 question on the mailing lists, I don't know the answer to start with. I just Google for the obvious terms and go from there. I do have the advantage of having been a professional programmer for 16 years, including 10 years of programming under Windows and sometimes in Windows, and 7 years of using Python. But I'm no rocket scientist, and a lot of the time the question isn't "How can I do this in Python?" but rather "How can I do this?" and the jump to Python is nearly trivial. There was a recent thread on python-dev in which GvR was surprised at the (large) number of .msi downloads from Python.org, indicating how popular Python might be among Windoweers. My personal quest is to encourage that popularity by answering as many Win32-related Python questions as I can and if I can generate (and maintain) useful and more Pythonic modules to support that, then I will. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From timr at probo.com Wed Dec 13 18:07:36 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 13 Dec 2006 09:07:36 -0800 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin In-Reply-To: References: Message-ID: <45803358.4010105@probo.com> Tim Golden wrote: > There was a recent thread on python-dev in which > GvR was surprised at the (large) number of .msi > downloads from Python.org, indicating how popular > Python might be among Windoweers. I'm surprised he was surprised. Better than 90% of the desktops in the world run Windows, so statistically speaking, 90% of the downloads should be from Windows users. (Note that I'm ignoring the inconvenient fact that a much lower percentage of those Windows users have are technically competent enough to be interested in Python at all.) The simple fact that the Windows command shell sucks means that we NEED tools more than the Linux community. Many of the jobs that I tackle with Python would be more appropriate with awk or bash or sed on Linux. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Tim.Golden at viacom-outdoor.co.uk Wed Dec 13 18:13:57 2006 From: Tim.Golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 13 Dec 2006 17:13:57 -0000 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin In-Reply-To: <45803358.4010105@probo.com> Message-ID: [Tim Roberts] | | Tim Golden wrote: | > There was a recent thread on python-dev in which | > GvR was surprised at the (large) number of .msi | > downloads from Python.org, indicating how popular | > Python might be among Windoweers. | | I'm surprised he was surprised. Better than 90% of the | desktops in the world run Windows, so statistically speaking, | 90% of the downloads should be from Windows users. I was a little underprecise in my report. He was actually surprised at the apparent upsurge in the percentage, not in the percentage itself. But still... The thread is here, in case you're interested: http://mail.python.org/pipermail/python-dev/2006-December/thread.html#70 291 TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From cappy2112 at gmail.com Wed Dec 13 18:55:24 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 13 Dec 2006 09:55:24 -0800 Subject: [python-win32] Python-win32 Digest, Vol 45, Issue 13 In-Reply-To: References: Message-ID: <8249c4ac0612130955t4c2be577seeb2131dfc485793@mail.gmail.com> >>wonderful Python-ish API on how to access for example Outlook Express You can go to the Microsoft MSDN site and look for the VBA reference for Outlook Express. In particular, search for the Outlook Express Object Hierarchy chart/reference. Without knowing this, the API's are pretty hard to use, unless you've done it before. You can also search on websites which have support for Visual Basic 6. There are a tremendous amount of programs written to interact with the Office applications from Visual Basic. I once wrote a Python script to pull names out of an Outlook distribution list. I started by finding out how Visual Basic called Outlook, and translated that to Python. VIsual Basic resources can be a bighelp. Good luck! From: "Bokverket" Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin To: Message-ID: Content-Type: text/plain; charset="iso-8859-1" Tim and Michael, I am a Python neophyte and must admit that I am not familiar with all those Python library names that swish around this list. But that was not my point. The tasks on Michael's list that he has done/helped out with lately are to a large extent useful jobs that an ordinary user would love. Well, at least one who know how to program, iow use Python as _the_ scripting language to glue all these Micrsoft parts and apps together. This would require a wonderful Python-ish API on how to access for example Outlook Express address lists, Word and the file system. Plus some wonderful examples of useful examples and how to execute them in a Window environment.. IOW, making Python for Windows what AWK was for DOS :-) Does this library already exist, easy-to-use? Maybe this would be another book project for you?! All the best, G?ran, Stockholm, Sweden -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061213/16568b09/attachment.html From shussai2 at yahoo.com Wed Dec 13 20:17:17 2006 From: shussai2 at yahoo.com (Sajjad Hussain) Date: Wed, 13 Dec 2006 11:17:17 -0800 (PST) Subject: [python-win32] USB Power Off from Python Message-ID: <20061213191717.3263.qmail@web36811.mail.mud.yahoo.com> Hi, I am using a USB port to power my USB device that takes 5V DC power. My device works fine and is powered on properly. I am using small script written in python to open a port (I am using a serial to usb adapter since my device has a serial connector on it), and send some data. Now I just want to turn off my device. Basically cutoff 5V usb power to my device. That means turn off power to a particular usb port where my device is connected to. And later say after 5 minutes I want to turn the power back on. I am using Windows XP. Please let me know how I can do that. Regards, Sajjad ____________________________________________________________________________________ Need a quick answer? Get one in minutes from people who know. Ask your question on www.Answers.yahoo.com From timr at probo.com Wed Dec 13 21:16:53 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 13 Dec 2006 12:16:53 -0800 Subject: [python-win32] USB Power Off from Python In-Reply-To: <20061213191717.3263.qmail@web36811.mail.mud.yahoo.com> References: <20061213191717.3263.qmail@web36811.mail.mud.yahoo.com> Message-ID: <45805FB5.2080604@probo.com> Sajjad Hussain wrote: > I am using a USB port to power my USB device that > takes 5V DC power. My device works fine and is powered > on properly. I am using small script written in python > to open a port (I am using a serial to usb adapter > since my device has a serial connector on it), and > send some data. > > Now I just want to turn off my device. Basically > cutoff 5V usb power to my device. That means turn off > power to a particular usb port where my device is > connected to. And later say after 5 minutes I want to > turn the power back on. I am using Windows XP. Please > let me know how I can do that. You can't. There is no mechanism in the Windows USB driver stack to perform this task. Not even a USB kernel driver can do this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nytrokiss at gmail.com Thu Dec 14 03:48:12 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 13 Dec 2006 21:48:12 -0500 Subject: [python-win32] USB Power Off from Python In-Reply-To: <45805FB5.2080604@probo.com> References: <20061213191717.3263.qmail@web36811.mail.mud.yahoo.com> <45805FB5.2080604@probo.com> Message-ID: <8a6b8e350612131848i49235b4ch653f185c99687957@mail.gmail.com> However we see that you can unmount it ans sometimes it will be turned off.... On 12/13/06, Tim Roberts wrote: > > Sajjad Hussain wrote: > > I am using a USB port to power my USB device that > > takes 5V DC power. My device works fine and is powered > > on properly. I am using small script written in python > > to open a port (I am using a serial to usb adapter > > since my device has a serial connector on it), and > > send some data. > > > > Now I just want to turn off my device. Basically > > cutoff 5V usb power to my device. That means turn off > > power to a particular usb port where my device is > > connected to. And later say after 5 minutes I want to > > turn the power back on. I am using Windows XP. Please > > let me know how I can do that. > > You can't. There is no mechanism in the Windows USB driver stack to > perform this task. Not even a USB kernel driver can do this. > > -- > 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 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061213/d28bcf37/attachment-0001.html From Mark at twitchstudios.com Thu Dec 14 04:37:55 2006 From: Mark at twitchstudios.com (Mark) Date: Thu, 14 Dec 2006 14:37:55 +1100 Subject: [python-win32] Client side COM and Python Problem Message-ID: <4580C713.6040502@twitchstudios.com> Hey Guys, Im new to working with com but i only want to do one thing. I have activestate python and am trying to get python to run a simple function in a com enabled 3d program called 3dsmax. If i try and execute a function over the com interface it works fine as long as i dont try and run the function with an argument. when i run it with an argument like so. "o.mypingmax("test string")" it gives me an error in my client app and an error in python. please help me understand this error and what i am doing wrong? I have tried a similar script in another language and it works. but python does not like it. #code import win32com.client o = win32com.client.Dispatch("MAX.Application.8") o.mypingmax("test string") # Python Error Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 491, in __getattr__ raise pythoncom.com_error, details com_error: (-2147220992, 'CONNECT_E_NOCONNECTION', None, None) #client Application error (3dsmax script output) -- Argument count error: mypingmax wanted 1, got 0 during OLE automation function call Sorry if its blindingly obvious but i just cant work out what is going on. Cheers, Mark From nytrokiss at gmail.com Thu Dec 14 05:38:43 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 13 Dec 2006 23:38:43 -0500 Subject: [python-win32] Python-win32 Digest, Vol 45, Issue 13 In-Reply-To: <8249c4ac0612130955t4c2be577seeb2131dfc485793@mail.gmail.com> References: <8249c4ac0612130955t4c2be577seeb2131dfc485793@mail.gmail.com> Message-ID: <8a6b8e350612132038n76828c3av64f7a1a5142344c2@mail.gmail.com> Wikipedia just opened a new hosting platform i will try to get a site and make a media wiki so people in the python world can read/write on win32 API's Etc..... Although it would kill allot of the traffic on this list i am sure no one would mind! On 12/13/06, Tony Cappellini wrote: > > >>wonderful Python-ish API on how to access for example Outlook Express > You can go to the Microsoft MSDN site and look for the VBA reference for > Outlook Express. > In particular, search for the Outlook Express Object Hierarchy > chart/reference. > Without knowing this, the API's are pretty hard to use, unless you've done > it before. > > You can also search on websites which have support for Visual Basic 6. > There are a tremendous amount of programs written to interact with the > Office applications from Visual Basic. > > I once wrote a Python script to pull names out of an Outlook distribution > list. I started by finding out how Visual Basic called Outlook, and > translated that to Python. VIsual Basic resources can be a bighelp. > > > Good luck! > > From: "Bokverket" > Subject: [python-win32] Python as scripting glue, WAS Python for > sysadmin > To: > Message-ID: < BAY111-DAV8A381C35E02D91275AA80B2D70 at phx.gbl> > Content-Type: text/plain; charset="iso-8859-1" > > Tim and Michael, > > I am a Python neophyte and must admit that I am not familiar with all > those > Python library names that swish around this list. But that was not my > point. > The tasks on Michael's list that he has done/helped out with lately are to > a > large extent useful jobs that an ordinary user would love. Well, at least > one who know how to program, iow use Python as _the_ scripting language to > glue all these Micrsoft parts and apps together. This would require a > wonderful Python-ish API on how to access for example Outlook Express > address lists, Word and the file system. Plus some wonderful examples of > useful examples and how to execute them in a Window environment.. > > IOW, making Python for Windows what AWK was for DOS :-) > > Does this library already exist, easy-to-use? > > Maybe this would be another book project for you?! > > > All the best, > > G?ran, > Stockholm, Sweden > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061213/a85dbfad/attachment.htm From mhammond at skippinet.com.au Thu Dec 14 07:20:37 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 14 Dec 2006 17:20:37 +1100 Subject: [python-win32] Client side COM and Python Problem In-Reply-To: <4580C713.6040502@twitchstudios.com> Message-ID: <2d4c01c71f47$f90c4b20$110a0a0a@enfoldsystems.local> > #code > import win32com.client > o = win32com.client.Dispatch("MAX.Application.8") > o.mypingmax("test string") > > # Python Error > > Traceback (most recent call last): > File "", line 1, in ? > File > "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line > 491, in __getattr__ > raise pythoncom.com_error, details > com_error: (-2147220992, 'CONNECT_E_NOCONNECTION', None, None) > > #client Application error (3dsmax script output) > > -- Argument count error: mypingmax wanted 1, got 0 > during OLE automation function call >From the "wanted 1, got 0" message, it appears that the problem is that Python first checks to see if there is a *property* named 'mypingmax' before checking if it is a method. The way Python works, that is hard to avoid. If the app returned a "normal" error code in that case things would march on fine. You could try calling the _FlagAsMethod method on the object. Something like: o = win32com.client.Dispatch("MAX.Application.8") o._FlagAsMethod("mypingmax") o.mypingmax("test string") That should prevent win32com from first checking if the item is a property. HTH, Mark From gagsl-p32 at yahoo.com.ar Thu Dec 14 10:01:40 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 14 Dec 2006 06:01:40 -0300 Subject: [python-win32] USB Power Off from Python In-Reply-To: <8a6b8e350612131848i49235b4ch653f185c99687957@mail.gmail.co m> References: <20061213191717.3263.qmail@web36811.mail.mud.yahoo.com> <45805FB5.2080604@probo.com> <8a6b8e350612131848i49235b4ch653f185c99687957@mail.gmail.com> Message-ID: <7.0.1.0.0.20061214060003.01db51a0@yahoo.com.ar> At Wednesday 13/12/2006 23:48, James Matthews wrote: >However we see that you can unmount it ans sometimes it will be turned off.... I think it's some kind of "soft" turn off; you send the device a command to shutdown self. The +5V stay there. -- Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From bokverket at hotmail.com Fri Dec 15 00:52:20 2006 From: bokverket at hotmail.com (Bokverket) Date: Fri, 15 Dec 2006 00:52:20 +0100 Subject: [python-win32] Python Windows on Wikipedia References: Message-ID: That's an absolutely fabolous idea. In particular, a lot of more general info on accessing Windows from Python (and maybe Python from a typical app like Microsoft Excel or Word) would fit there. The things that one dare not ask here, in spite of the "no-dumb policy" :-) In fact I think that it would increase the traffic on this list due to a whole new group of people joining. The problem is that the learning curve is steep if you want to do something, start reading on this site, my problem is maybe typical that I read the book/chapter on Python and Windows long ago and got a canonical Hello World app to run (I managed to open Word from Python and was proud). Maybe there are good books or online resources on how to get a library up and running, what libraries are needed etc, how a COM works in conjunction with Pyton, etc., if so they could just be referenced. The target-group of the text ought to be programmers needing some glue. Best, Goran (Will comment on Tim G's post later, 1 a.m. here in Sweden :-) From nytrokiss at gmail.com Fri Dec 15 04:35:23 2006 From: nytrokiss at gmail.com (James Matthews) Date: Thu, 14 Dec 2006 22:35:23 -0500 Subject: [python-win32] Python Windows on Wikipedia In-Reply-To: References: Message-ID: <8a6b8e350612141935h666d3e14j56d8560813d9c288@mail.gmail.com> I agree it will have to address every concern out there but in the end i think it will work! On 12/14/06, Bokverket wrote: > > That's an absolutely fabolous idea. In particular, a lot of more general > info on accessing Windows from Python (and maybe Python from a typical app > like Microsoft Excel or Word) would fit there. The things that one dare > not > ask here, in spite of the "no-dumb policy" :-) > > In fact I think that it would increase the traffic on this list due to a > whole new group of people joining. The problem is that the learning curve > is steep if you want to do something, > start reading on this site, my problem is maybe typical that I read the > book/chapter on Python and Windows long ago and got a canonical Hello > World > app to run (I managed to open Word from Python and was proud). Maybe there > are good books or online resources on how to get a library up and running, > what libraries are needed etc, how a COM works in conjunction with Pyton, > etc., if so they could just be referenced. > > The target-group of the text ought to be programmers needing some glue. > > Best, > > Goran > (Will comment on Tim G's post later, 1 a.m. here in Sweden :-) > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061214/7e27980f/attachment.html From nytrokiss at gmail.com Fri Dec 15 04:36:24 2006 From: nytrokiss at gmail.com (James Matthews) Date: Thu, 14 Dec 2006 22:36:24 -0500 Subject: [python-win32] USB Power Off from Python In-Reply-To: <7.0.1.0.0.20061214060003.01db51a0@yahoo.com.ar> References: <20061213191717.3263.qmail@web36811.mail.mud.yahoo.com> <45805FB5.2080604@probo.com> <8a6b8e350612131848i49235b4ch653f185c99687957@mail.gmail.com> <7.0.1.0.0.20061214060003.01db51a0@yahoo.com.ar> Message-ID: <8a6b8e350612141936j2952e7bayfc7351008518f3ab@mail.gmail.com> ok thanks On 12/14/06, Gabriel Genellina wrote: > > At Wednesday 13/12/2006 23:48, James Matthews wrote: > > >However we see that you can unmount it ans sometimes it will be turned > off.... > > I think it's some kind of "soft" turn off; you send the device a > command to shutdown self. The +5V stay there. > > > -- > Gabriel Genellina > Softlab SRL > > __________________________________________________ > Correo Yahoo! > Espacio para todos tus mensajes, antivirus y antispam ?gratis! > ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061214/c28e7588/attachment.htm From bgailer at alum.rpi.edu Fri Dec 15 06:44:42 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 14 Dec 2006 21:44:42 -0800 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin In-Reply-To: References: Message-ID: <4582364A.80006@alum.rpi.edu> Bokverket wrote: > Tim and Michael, > > I am a Python neophyte and must admit that I am not familiar with all those > Python library names that swish around this list. But that was not my point. > The tasks on Michael's list that he has done/helped out with lately are to a > large extent useful jobs that an ordinary user would love. Well, at least > one who know how to program, iow use Python as _the_ scripting language to > glue all these Micrsoft parts and apps together. This would require a > wonderful Python-ish API on how to access for example Outlook Express > address lists, Word and the file system. Plus some wonderful examples of > useful examples and how to execute them in a Window environment.. > > IOW, making Python for Windows what AWK was for DOS :-) > I'm confused. http://www.vectorsite.net/tsawk.html states "The Awk text-processing programming language is a useful and simple tool for manipulating text". I don't see anything like "access for example Outlook Express address lists, Word, ..." > Does this library already exist, easy-to-use? > I have under development a Python implementation of IBM's CMS Pipelines, which is in essence a "super AKW and Linux/Unix pipes" all in 1 package. Would you like to hear more? -- Bob Gailer 510-978-4454 From mail at timgolden.me.uk Fri Dec 15 15:43:29 2006 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 15 Dec 2006 14:43:29 -0000 (GMT) Subject: [python-win32] Python Windows on Wikipedia In-Reply-To: References: Message-ID: <38539.81.171.156.66.1166193809.squirrel@81.171.156.66> [James Matthews] | Wikipedia just opened a new hosting platform i will try to | get a site and make a media wiki so people in the python | world can read/write on win32 API's Etc..... Although it | would kill allot of the traffic on this list [Bokverket] > That's an absolutely fabolous idea. In particular, a > lot of more general info on accessing Windows from > Python (and maybe Python from a typical app > like Microsoft Excel or Word) would fit there. > The things that one dare not ask here, > in spite of the "no-dumb policy" :-) > Maybe there are good books or online resources on > how to get a library up and running, what libraries > are needed etc, how a COM works in conjunction with Pyton, > etc., if so they could just be referenced. > The target-group of the text ought to be programmers > needing some glue. I'd prefer to use the python.org wiki if anything. Provision of wiki space isn't really an issue. Rather, it's gaining and sustaining the momentum to keep the thing going that's the problem. Having sthg on the python site would give just a certain edge of official feel to it. As has been noted several times over the years -- and most recently and forcefully by Fredrik Lundh -- Python could benefit from some more community-contributable documentation system. One of our problems at the moment is that lack of focus, of "brand" if you like marketing terms. (Sorry, I work for an advertising company). I'm not a great fan of wikis as such, but I recognise that ease-of-update increases the likelihood of contribution and reduces the adminstration bottleneck which relies on someone to vet and/or edit contributions. Obviously this is all pie-in-the-sky until someone does something. I suggest that unless someone comes back by tomorrow to object, I'll create a PythonUnderWindows main page on the Python Wiki with an Sysadmin page underneath. (It's not as though we can't move it later if we need to). If someone ones to get their own scheme running first, then feel free and I'll happily contribute. TJG From cappy2112 at gmail.com Fri Dec 15 18:57:26 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 15 Dec 2006 09:57:26 -0800 Subject: [python-win32] Python Windows on Wikipedia Message-ID: <8249c4ac0612150957m3abbc7f7l59db0eedf5be2487@mail.gmail.com> Message: 1 Date: Fri, 15 Dec 2006 00:52:20 +0100 From: "Bokverket" Subject: [python-win32] Python Windows on Wikipedia To: Message-ID: Content-Type: text/plain; charset="iso-8859-1" Regarding you comment about resources for Python & COM http://www.oreilly.com/catalog/pythonwin32/ http://www.devshed.com/c/a/Python/Windows-Programming-in-Python/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061215/402cc1ff/attachment.htm From bgailer at alum.rpi.edu Fri Dec 15 21:03:13 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 15 Dec 2006 12:03:13 -0800 Subject: [python-win32] Python Windows on Wikipedia In-Reply-To: <38539.81.171.156.66.1166193809.squirrel@81.171.156.66> References: <38539.81.171.156.66.1166193809.squirrel@81.171.156.66> Message-ID: <4582FF81.5080303@alum.rpi.edu> Tim Golden wrote: > One of our problems at the moment is that lack of focus, of "brand" if you like marketing terms. (Sorry, I work for an advertising company). I'm glad to hear you mention "brand". I've attended several business seminars (Income Builders International). I heard a lot of talk about branding, but no explanation of how it would apply to a software product. I always thought it was something one applied to hard goods. Then I realized that it applied to the software I was developing. So now I cherish the concept. How do you see Python benefiting from branding? -- Bob Gailer 510-978-4454 From bokverket at hotmail.com Fri Dec 15 22:09:21 2006 From: bokverket at hotmail.com (Bokverket) Date: Fri, 15 Dec 2006 22:09:21 +0100 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin Message-ID: Bob wrote: > IOW, making Python for Windows what AWK was for DOS :-) > I'm confused. http://www.vectorsite.net/tsawk.html states "The Awk text-processing programming language is a useful and simple tool for manipulating text". I don't see anything like "access for example Outlook Express address lists, Word, ..." -- They are zillions of years in the history of computing apart, i.e. almost 40 :-) Some people think that Python owes something to AWK, though, for instance it had associative arrays already from its outset. Quite advanced for its time. You are definitely right about it being very pipe-oriented; I did not think of it in that way. The analogy was just that awk became widely use as a scripting language. Windows was unheard of when it was developed, in fact it even predates PC-DOS, so Bill Gates had not even started on his learning curve. Now we have typical Windows app but a lousy scripting environment/language (I think), thus my original post. What you say below sounds great. I have under development a Python implementation of IBM's CMS Pipelines, which is in essence a "super AKW and Linux/Unix pipes" all in 1 package. Would you like to hear more? -- Indeed. Best, Goran From timr at probo.com Fri Dec 15 22:42:02 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 15 Dec 2006 13:42:02 -0800 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin In-Reply-To: References: Message-ID: <458316AA.9020609@probo.com> Bokverket wrote: > Bob wrote: > >> IOW, making Python for Windows what AWK was for DOS :-) >> > I'm confused. http://www.vectorsite.net/tsawk.html states "The Awk > text-processing programming language is a useful and simple tool for > manipulating text". I don't see anything like "access for example > Outlook Express address lists, Word, ..." > -- They are zillions of years in the history of computing apart, i.e. almost > 40 :-) > ??? Windows and awk are only 10 years apart, and Word only about 5 years after that. > Some people think that Python owes something to AWK, though, for instance it > had associative arrays already from its outset. Quite advanced for its time. > Perl is a rather direct descendent of awk. In the early days, Perl could actually run many awk scripts virtually unchanged. However, the connection from awk to Python is much more oblique. For example, Snobol had associative arrays long before awk was developed. > You are definitely right about it being very pipe-oriented; I did not think > of it in that way. The analogy was just that awk became widely use as a > scripting language. Yes, but not on DOS or on Windows. No PC version of awk ever included COM support. > Windows was unheard of when it was developed, in fact > it even predates PC-DOS, so Bill Gates had not even started on his learning > curve. Well, the Microsoft Corporation pre-dates awk, so Bill was certainly on his way to total world domination by then... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jesus at aguillon.com Fri Dec 15 23:21:17 2006 From: jesus at aguillon.com (Jesus Aguillon) Date: Fri, 15 Dec 2006 14:21:17 -0800 Subject: [python-win32] Strange printing with Pythonwin In-Reply-To: References: Message-ID: Hello all, I am experiencing a problem when I try to print a script from within PythonWin. I will occasionally only get blank pages printed. When I try to preview the print it will also show blank pages. It seems that this is an intermittent problem since at times it will print correctly. Has anyone experienced a similar issue? I am running on Windows XP SP2 and the following is displayed when I bring up PythonWin. PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> C:\Python25\Lib\site-packages\pythonwin\pywin\scintilla\view.py:641: DeprecationWarning: 'L' format requires 0 <= number <= 4294967295 fr = struct.pack('LLIIIIIIIIll', hdcRender, hdcFormat, rc[0], rc[1], rc[2], rc[3], rc[0], rc[1], rc[2], rc[3], pageStart, lengthDoc) Thank you, -- jesusATaguillonDOTcom -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061215/70169047/attachment.html From rwupole at msn.com Sat Dec 16 12:55:43 2006 From: rwupole at msn.com (Roger Upole) Date: Sat, 16 Dec 2006 06:55:43 -0500 Subject: [python-win32] Re: Strange printing with Pythonwin Message-ID: Jesus Aguillon wrote: > Hello all, > I am experiencing a problem when I try to print a script from within > PythonWin. I will occasionally only get blank pages printed. When I try > to preview the print it will also show blank pages. It seems that this is > an intermittent problem since at times it will print correctly. Has anyone > experienced a similar issue? > > I am running on Windows XP SP2 and the following is displayed when I bring > up PythonWin. > > PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] > on win32. > Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for > further copyright information. >>>> C:\Python25\Lib\site-packages\pythonwin\pywin\scintilla\view.py:641: > DeprecationWarning: 'L' format requires 0 <= number <= 4294967295 > fr = struct.pack('LLIIIIIIIIll', hdcRender, hdcFormat, rc[0], rc[1], > rc[2], rc[3], rc[0], rc[1], rc[2], rc[3], pageStart, lengthDoc) > > Thank you, > -- > jesusATaguillonDOTcom >From looking at the struct.pack format, I think you're running into DC handles with negative values. Pywin32 treats handles as signed longs. There appears to be a difference in how 2.4 and 2.5 handle them: 2.4: >>> struct.pack('l',-4100000) '`p\xc1\xff' >>> struct.pack('L',-4100000) '`p\xc1\xff' 2.5: >>> struct.pack('l',-4100000) '`p\xc1\xff' >>> struct.pack('L',-4100000) __main__:1: DeprecationWarning: 'L' format requires 0 <= number <= 4294967295 '\x00\x00\x00\x00' Try changing the sruct.pack format to lower case l's, and if that solves your problem I'll change it in CVS. Roger From fuzzyman at voidspace.org.uk Sat Dec 16 19:26:24 2006 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 16 Dec 2006 18:26:24 +0000 Subject: [python-win32] Pythonwin Problems Message-ID: <45843A50.1080204@voidspace.org.uk> Hello all, There are various problems with Pythonwin under Movable Python. The latest that I have discovered is that Pythonwin fails to bring up the find dialog the *second* time you use it. It fails with the following traceback : Traceback (most recent call last): File "\movpy\lib\pythonwin\pywin\scintilla\view.py", line 349, in OnCmdEditFind find.ShowFindDialog() File "\movpy\lib\pythonwin\pywin\scintilla\find.py", line 36, in ShowFindDialog _ShowDialog(FindDialog) File "\movpy\lib\pythonwin\pywin\scintilla\find.py", line 53, in _ShowDialog curDialog.CreateWindow() win32ui: CreateIndirect failed win32ui: Error in Command Message handler for command ID 57636, Code 0 Anyone got any clues as to what may be causing this ? There are a couple of other dialog related failures as well, but I've found workarounds for these (so far). Fuzzyman http://www.voidspace.org.uk/index2.shtml -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.21/589 - Release Date: 15/12/2006 From bgailer at alum.rpi.edu Sun Dec 17 03:31:39 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sat, 16 Dec 2006 18:31:39 -0800 Subject: [python-win32] Python as scripting glue, WAS Python for sysadmin In-Reply-To: References: Message-ID: <4584AC0B.6060906@alum.rpi.edu> Bokverket wrote: > Bob Gailer's keyboard emitted: > > I have under development a Python implementation of IBM's CMS Pipelines, > which is in essence a "super AKW and Linux/Unix pipes" all in 1 package. > Would you like to hear more? > > -- Indeed. NOTES FOR INTERESTED USERS/DEVELOPERS My work is a PC "version" of IBM's CMS Pipelines. See wikipedia for how CMS Pipelines is an extension of the unix concept: http://en.wikipedia.org/wiki/Hartmann_pipeline also from wikipedia "CMS Pipelines is a port of the pipeline idea to VM/CMS and MVS systems. It supports much more complex pipeline structures than Unix shells, with steps taking multiple input streams and producing multiple output streams. (Such functionality is supported by the Unix kernel, but few programs use it.) Due to the different nature of IBM mainframe operating systems, it implements many steps inside CMS Pipelines which in Unix are separate external programs, but can also call separate external programs for their functionality. Also, due to the record-oriented nature of files on IBM mainframes, pipelines operate in a record-oriented, rather than stream-oriented manner." Suggested reading: reference manual: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/FRAMESET/HCSG5A20/CCONTENTS?SHELF=HCSH2A50&DN=SC24-5971-00&DT=20001214155915 user guide: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/FRAMESET/HCSH1A20/CCONTENTS?SHELF=HCSH2A50&DN=SC24-5970-00&DT=20001214154939 Start with the reference. Much of the initial material will seem simple, as it is basic pipe stuff. But scan thru and keep reading. 1.1.6 Built-in Stage has a like to the built-in stages. This list is important. I'm implementing some but not all of them, as some are mainframe-specific, and some are way too complex for now. 1.1.7 User-Written Stage refers to REXX - substitute Python for REXX here and anywhere else. 1.1.8 Filter - filters are listed and discussed in the user guide chapter 2. I would stop at the end of chapter 3 in the reference. In the user guide chapter 1 repeats some of the reference, but is worth at least a scan. Chapter 2 Filters is crucial 3 Host Commands is mainframe-specific. Replace this with our ability to run and interact with processes from Python 4 Device Drivers is important, translating of course from mainframe to PC 5 Writing Stages - refers to REXX and Assember. Replace with Python and understand my user-written stage uses a different model. 6 Multistream Pipelines is also VERY important. This is one of the extensions over unix pipes. -- Bob Gailer 510-978-4454 From jesus at aguillon.com Sun Dec 17 21:53:57 2006 From: jesus at aguillon.com (Jesus Aguillon) Date: Sun, 17 Dec 2006 12:53:57 -0800 Subject: [python-win32] Strange printing with Pythonwin Message-ID: > > > Jesus Aguillon wrote: > > Hello all, > > I am experiencing a problem when I try to print a script from within > > PythonWin. I will occasionally only get blank pages printed. When I > try > > to preview the print it will also show blank pages. It seems that this > is > > an intermittent problem since at times it will print correctly. Has > anyone > > experienced a similar issue? > > > > I am running on Windows XP SP2 and the following is displayed when I > bring > > up PythonWin. > > > > PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit > (Intel)] > > on win32. > > Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' > for > > further copyright information. > >>>> C:\Python25\Lib\site-packages\pythonwin\pywin\scintilla\view.py:641: > > DeprecationWarning: 'L' format requires 0 <= number <= 4294967295 > > fr = struct.pack('LLIIIIIIIIll', hdcRender, hdcFormat, rc[0], rc[1], > > rc[2], rc[3], rc[0], rc[1], rc[2], rc[3], pageStart, lengthDoc) > > > > Thank you, > > -- > > jesusATaguillonDOTcom > > >From looking at the struct.pack format, I think you're running into DC > handles > with negative values. Pywin32 treats handles as signed longs. > There appears to be a difference in how 2.4 and 2.5 handle them: > > 2.4: > >>> struct.pack('l',-4100000) > '`p\xc1\xff' > >>> struct.pack('L',-4100000) > '`p\xc1\xff' > > > 2.5: > >>> struct.pack('l',-4100000) > '`p\xc1\xff' > >>> struct.pack('L',-4100000) > __main__:1: DeprecationWarning: 'L' format requires 0 <= number <= > 4294967295 > '\x00\x00\x00\x00' > > Try changing the sruct.pack format to lower case l's, and if that solves > your problem > I'll change it in CVS. > > Roger I changed to lower case l's and that seems to have done the job. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061217/858c0306/attachment.htm From it at crummock.com Mon Dec 18 14:37:52 2006 From: it at crummock.com (Ross McKerchar) Date: Mon, 18 Dec 2006 13:37:52 +0000 Subject: [python-win32] extending com objects Message-ID: <458699B0.8000801@crummock.com> Could somebody please confirm that my objectives below are neither 1) Reinventing the wheel or 2) Attempting something that has deliberately _not_ been done by someone far wiser than me. Put simply I want to extend a com object, which, if I understand correctly is not possible in the "normal" [i.e. class Square(Shape):] way. To do this my aim was to implement something akin to a simpler & more generic version of Tim Golden's wmi stuff (which I find amazingly useful - thanks!). Specifically: create a class to transparently wrap a generic com object, so that, if the wrapper class didn't have a method or an attribute I would catch the error and try calling the same method/attribute on the object I was wrapping (using some getattr & setattr black magic). Should I get coding or am I missing something? thanks, -ross From Craig.Charlton.ctr at losangeles.af.mil Wed Dec 20 00:24:05 2006 From: Craig.Charlton.ctr at losangeles.af.mil (Charlton, Craig A Ctr SMC/ISA) Date: Tue, 19 Dec 2006 15:24:05 -0800 Subject: [python-win32] Excel sort error with Python 2.2.3 & early binding Message-ID: I am using Python 2.2.3 with Pywin32-210.win32-py2.2 The following Python sequence works fine when using the 'late binding' method. import win32com.client.dynamic import types xlApp = win32com.client.Dispatch("Excel.Application") xlBook = xlApp.Workbooks.Open( 'C:\\TestExcel.xls' ) sheet = xlBook.Worksheets( 1 ) sheet.Activate() rangeToSort = xlApp.Range('a2:e5') rangeToSort.Sort( Key1=sheet.Columns( 3 ), Order1=1 , Header=1 ) Since I required the use of the GetOffset function when using COM with Excel, I compiled the Excel 11.0 Object Library using the COM MakePy Utility in PythonWin. When I run the above sequence now, I get the following error. If I then delete the generated Excel 11.0 .py file in the win32com\gen_py directory. The sequence will then run without a problem. Traceback (most recent call last): File "C:\Python22\Tools\idle\Debugger.py", line 37, in run return apply(bdb.Bdb.run, (self,) + args) File "C:\Python22\lib\bdb.py", line 349, in run exec cmd in globals, locals File "", line 1, in ? rangeToSort.Sort( Key1=sheet.Columns( 3 ), Order1=1 , Header=1 ) File "C:\Python22\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-0 00000000046x0x1x5.py", line 22609, in Sort, SortMethod, DataOption1, DataOption2, DataOption3) File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Office Excel', "The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank.", 'C:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\xlmain11.chm', 0, -2146827284), None) Varying the setting of the 'bForDemand' parameter did not seems to affect the problem behavior. I am using Python 2.2.3 in conjunction with a 3rd party app and do not have the option of moving to a upgraded/fixed version of Python at this time. One workaround that I have is to remove the generated Excel 11.0 .py file and no longer use the GetOffset call in my Python code, but wondered if there is a known fix to the above problem. Thanks, Craig From rwupole at msn.com Wed Dec 20 01:34:52 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 19 Dec 2006 19:34:52 -0500 Subject: [python-win32] Re: Excel sort error with Python 2.2.3 & early binding Message-ID: I think the problem is with the default value for the keys that aren't specified. This works with both early and late binding: rangeToSort.Sort( Key1=sheet.Columns( 3 ), Order1=1 , Header=1, Key2=pythoncom.Missing, Key3=pythoncom.Missing ) Roger From Craig.Charlton.ctr at losangeles.af.mil Wed Dec 20 03:03:40 2006 From: Craig.Charlton.ctr at losangeles.af.mil (Charlton, Craig A Ctr SMC/ISA) Date: Tue, 19 Dec 2006 18:03:40 -0800 Subject: [python-win32] Excel sort error with Python 2.2.3 & earlybinding In-Reply-To: <001201c723ce$abad6090$0100a8c0@rupole> Message-ID: I ran my test with the 'optional' arguments defined as pythoncom.Missing and it does work now. Previously my code was working under a very old Python 1.5.2 where the 'defaultNamedNotOptArg' was defined as pythoncom.Missing in the .py file generated for the Excel 11.0 Object Library. Evidently the more recent Pywin32 for 2.2.3 has defined these optional arguments as pythoncom.Empty and thus the error was occurring. I expect there was some rationale for changing the defaults, but it seems an 'optional' argument would want to use Missing rather than Empty. I'm not an expert by any means though, so will do what works. Thanks for pointing out the solution to my problem. -Craig From warbands at mac.com Wed Dec 20 03:06:43 2006 From: warbands at mac.com (Chris Rock) Date: Tue, 19 Dec 2006 18:06:43 -0800 Subject: [python-win32] PYTHONPATH and .pth files under Windows XP Message-ID: <987DF09C-010F-1000-AC73-541A781B61E1-Webmail-10023@mac.com> PYTHONPATH and .pth files under Windows XP No matter what my PYTHONPATH is set to as a Enivorment Variable under Windows XP, the only time a .pth file is actually being read and used is when I dump it into my site-packages directory off my install location. lets say I have the following directory structure: c:\dev\Python .\Lib .\Database .\String Now lets say I have a module named Database.py sitting in the directory c:\dev\Python\Lib\Database\ I would like to have PYTHONPATH set to c:\dev\Python\Lib I would then like to have a Lib.pth file that has relative directory locations in the file: such as "Database\", "String\" and so on for all the major Module Directories. So in my main python program I would like to have the call: import Database Then use my module like: Database.Method() Ultimately we would like to control which work tree we would use, so that we have a "c:\dev" area, and we may have a "m:\release" area. By tuning our PYTHONPATH to reflect which tree we would like to use as a base this should be fairly doable, and works great for our Mel development. .... So the question is, the only way this works is by hand placing my Lib.pth under my python install directory's site-packages directory, and I have to use a full path reference. So what I am doing wrong, or forgetting? I have been constantly checking my path via sys.path, and it only reflects the .pth file when it is in the site-packages directory. Using the site-packages directory is NOT GOING TO WORK for our usage. I eagerly await any thoughts on this, thanks in advance. - Rock From mhammond at skippinet.com.au Wed Dec 20 06:15:49 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 20 Dec 2006 16:15:49 +1100 Subject: [python-win32] PYTHONPATH and .pth files under Windows XP In-Reply-To: <987DF09C-010F-1000-AC73-541A781B61E1-Webmail-10023@mac.com> Message-ID: <38cd01c723f5$eb69fd20$110a0a0a@enfoldsystems.local> > PYTHONPATH and .pth files under Windows XP > > No matter what my PYTHONPATH is set to as a Enivorment > Variable under Windows XP, the only time a .pth file is > actually being read and used is when I dump it into my > site-packages directory off my install location. A quick scan of http://docs.python.org/lib/module-site.html shows that Python doesn't promise to offer the behaviour you desire on any platform. Check out site.py in the Python Lib directory, specifically addsitepackages - that is just the code that implements the documented behaviour, but it will at least give you insights into how you might be able to exploit it. An alternative is to have your code do: import site site.addsitedir(your_dir) Which should cause any .pth files in your_dir to be picked up. HTH, Mark From cappy2112 at gmail.com Wed Dec 20 19:20:56 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 20 Dec 2006 10:20:56 -0800 Subject: [python-win32] List of drives / removable drives Message-ID: <8249c4ac0612201020jfb94d0buaa9a2063742fa938@mail.gmail.com> Is there a way to differentiate between floppy, network, hard drive, removable (aka USB flash) drives? though Pythonwin? My searches came up with Tim Golden's mapped drives, which is somewhat helpful, but not particular to my needs. http://tgolden.sc.sabren.com/python/win32_how_do_i/show_mapped_drives.html win32api.GetVolumeInformation doesn't return anything specific- other than 'FAT' which is used on a floppy, but somehow I was expecting something a little more specific. thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061220/2d749903/attachment.html From rwupole at msn.com Wed Dec 20 23:02:25 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 20 Dec 2006 17:02:25 -0500 Subject: [python-win32] Re: List of drives / removable drives Message-ID: Tony Cappellini wrote: > Is there a way to differentiate between floppy, network, hard drive, > removable (aka USB flash) drives? though Pythonwin? > > My searches came up with Tim Golden's mapped drives, which is somewhat > helpful, but not particular to my needs. > http://tgolden.sc.sabren.com/python/win32_how_do_i/show_mapped_drives.html > > win32api.GetVolumeInformation doesn't return anything specific- other than > 'FAT' which is used on a floppy, but somehow > I was expecting something a little more specific. > > > thanks win32file.GetDriveType will tell you this. Roger From howard at eegsoftware.com Thu Dec 21 01:17:42 2006 From: howard at eegsoftware.com (Howard Lightstone) Date: Wed, 20 Dec 2006 16:17:42 -0800 Subject: [python-win32] List of drives / removable drives In-Reply-To: <8249c4ac0612201020jfb94d0buaa9a2063742fa938@mail.gmail.com> References: <8249c4ac0612201020jfb94d0buaa9a2063742fa938@mail.gmail.com> Message-ID: <45896226.5390.61FD5D8@howard.eegsoftware.com> > > > Is there a way to differentiate between floppy, network, hard drive, removable (aka USB flash) > drives? though Pythonwin? > > My searches came up with Tim Golden's mapped drives, which is somewhat helpful, but not > particular to my needs. > http://tgolden.sc.sabren.com/python/win32_how_do_i/show_mapped_drives.html > > win32api.GetVolumeInformation doesn't return anything specific- other than 'FAT' which is used > on a floppy, but somehow > I was expecting something a little more specific. How about (untried but ...) drivebits=win32file.GetLogicalDrives() for d in range(1,26): mask=1 << d if drivebits & mask: # here if the drive is at least there drname='%c:\\' % chr(ord('A')+d) t=win32file.GetDriveType(drname) if t == win32file.DRIVE_REMOVABLE: Or whatever DRIVE_* defined values there are in win32file DRIVE_CDROM DRIVE_FIXED DRIVE_NO_ROOT_DIR DRIVE_RAMDISK DRIVE_REMOTE DRIVE_REMOVABLE DRIVE_UNKNOWN -- Howard Lightstone www.eegsoftware.com howard at eegsoftware.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061220/e19693f8/attachment.htm From cappy2112 at gmail.com Thu Dec 21 02:36:33 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 20 Dec 2006 17:36:33 -0800 Subject: [python-win32] List of drives / removable drives In-Reply-To: <45896226.5390.61FD5D8@howard.eegsoftware.com> References: <8249c4ac0612201020jfb94d0buaa9a2063742fa938@mail.gmail.com> <45896226.5390.61FD5D8@howard.eegsoftware.com> Message-ID: <8249c4ac0612201736p91d73fcjbf99fd6b5784c9e8@mail.gmail.com> Will try this- thanks On 12/20/06, Howard Lightstone wrote: > > > > > > > Is there a way to differentiate between floppy, network, hard drive, > removable (aka USB flash) > > drives? though Pythonwin? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061220/88906588/attachment.htm From it at crummock.com Thu Dec 21 14:23:55 2006 From: it at crummock.com (Ross McKerchar) Date: Thu, 21 Dec 2006 13:23:55 +0000 Subject: [python-win32] extending com objects In-Reply-To: <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> References: <458699B0.8000801@crummock.com> <39238.81.171.156.66.1166451212.squirrel@81.171.156.66> Message-ID: <458A8AEB.8050905@crummock.com> Tim Golden wrote: > As you will realise if you've looked at my code, I'm > using a delegation model. (Sounds grand, doesn't it: > a delegation model!) Which basically means I keep > a copy of the WMI COM object inside my own class and > proxy things across where needed. > > Can't see why you couldn't do this with any other > kind of COM object in the same way. Might not be > the quickest technique -- you're adding another > layer to sthg which already has a couple -- but > maybe that's not a problem. > Yep, my plan was to wrap the class and use some getattr/setattr magic to decide when to delegate my requests to the com object (a delegation model does sound like a better way of putting it :). Efficiency is not a huge problem for the application I have in mind. My main worry about attempting it was that there might already a simple elegant way of doing it, or, a good reason why I shouldn't. I'd have thought the ability to extend com objects would be commonly required and hence addressed before but obviously not. Wont manage to sort something out till well into the new year but I'll post a link to it when I'm done - I figure what I come up with should be applicable to any and all com objects. thanks, -ross From tschaible at gmail.com Thu Dec 21 16:08:56 2006 From: tschaible at gmail.com (Tom Schaible) Date: Thu, 21 Dec 2006 10:08:56 -0500 Subject: [python-win32] Makepy and Documentum Foundation Classes Message-ID: <85646c00612210708he31cd43ye91386edd45e0c55@mail.gmail.com> Hello everyone, Just seeing if I can open up this issue with a bit more information. I am trying to access the COM interface to Documentum as well. I ran into the same problems that David did. Basically, that it appears makepy gets utterly confused when generating the information for the DFC COM interface. Makepy runs, without any errors, but the outputted library information is incorrect. I did some inspection myself to see what's up. As an example, I'll take the IDfClientX interface, and specifically, the getDFCVersion() method that takes no parameters. After creating, Makepy, the definition is as follows in the generated code. def getDFCVersion(self): # Result is a Unicode object - return as-is for this version of Python return self._oleobj_.InvokeTypes(23, LCID, 1, (8, 0), (),) Now if I'm running things myself after Makepy, and I have an IDfClientX object, if I call GetTypeInfo(23) on the _oleobj_ of the IDfClientX object, I get the typeinfo for the method. If I call GetFuncDesc(23).memid I get 17. If I call GetIDsOfNames(_oleobj_.GetTypeInfo(i).GetDocumentation(i)[0]), I get 40, which is the correct value. If I go back to the generated code from Makepy, and manually change all references of 23 to 40 for getDFCVersion, the call to this method will work correctly. I attempted to inspect MakePy.py to see if I could simply add a call to GetIDsOfNames to get the correct ID, but unfortunately this fails. I put in some logging information for MakePy before the _AddFunc_ method of build.py, just before an entry is added to the function map. When the entry is added, a call to GetIDsofNames returns 23, and the funcdesc.memid variable is also 23. I can get no reference to the correct ID of 40. In short, it appears that during generation, MakePy's calls to get ids only returns the index of the method in the COM interface (i.e. the x you need to put in GetTypeInfo(x) to get the TypeInfo. Anyone have any ideas here, I'll be the first to admit, I only have limited knowledge of Python and COM. It seems that there should be a way to coax correct values out of this since Python is cabable of getting the correct IDs. Any help is appreciated. Thanks, --Tom With carefully-arranged electrons, Mark Hammond wrote: > > Unfortunately, the dynamic dispatch and makepy utilities don't get the > > correct IDs for the various methods -- which are often object factories > > that lead to more dispatches. > > I'm not sure what you mean by "dynamic dispatch", but if you explicitly use > win32*com*.client.dynamic.DumpDispatch(), you should find the object is only > calling GetIDsFromNames() on the object (which you later said does work). By dynamic dispatch, I was referring to simply calling win32*com*.client.dynamic.Dispatch(). What's really interesting is that I get a third result from doing the DumbDispatch(); in that case the methods on the object return a string with the *Java* object name. So the *COM*-*Java* bridge (or something about the underlying *Java* implementation) seems to be at work here. The type library has the right types, but the wrong enumeration of dispid's. > > However, makepy (and a normal Dispatch() in many cases) does things > differently - it asks the object for its "typeinfo", and builds up a map of > all the available methods and properties. > > As the win32*com* dispid mapping works for the vast majority of objects, it > would appear possible that the typeinfo retrieved for the object is not > accurate. > Okay, that makes sense. At least that would let me go back to the vendor and request that they update their typelib. [image: :-)] > > Obviously, manually going through the generated file and updating the > > IDs is not a great solution, so I'd like to patch build.py... > > > > But I really have no idea where to start. Any hints? Even an idea of > > what methods to look at would be much appreciated. > > I've no idea where to start as I've no idea what kind of patch you are > after. Looking at the _Build_Interface() method in win32*com*\client\genpy.py > would be a reasonable start, and is probably the place where we iterate over > the typeinfo and get the (apparently wrong) dispid and param information. I was hoping for something that would allow build.py to detect this case and handle it; of course based on what we've found that might not be possible. > > Oh, I should mention that Documentum's *COM* objects are implemented via > > the *COM*-*Java* bridge, which could be related, though I'm not sure. > > That certainly sounds a likely candidate - OTOH, if the bridge itself is > incorrect I'd expect other languages that introspect the typeinfo to also > fail in similar ways. Sadly, VBScript is probably unable to use the > typeinfo in that way, and depending on how the interface is defined, VB > itself may just jump directly to the vtable interface and also avoid getting > IDispatch info from the typelib. Is there any way to use the vtable interface through win32*com*? Thanks for your prompt reply to my somewhat vague questions [image: :-)] dave -- David W. Harks psys.org> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061221/44cb700f/attachment.htm From theller at ctypes.org Thu Dec 21 19:38:14 2006 From: theller at ctypes.org (Thomas Heller) Date: Thu, 21 Dec 2006 19:38:14 +0100 Subject: [python-win32] comtypes In-Reply-To: <457834D8.7070401@vintech.bg> References: <45783047.1090400@ctypes.org> <457834D8.7070401@vintech.bg> Message-ID: Niki Spahiev schrieb: > Thomas Heller wrote: >> comtypes seems to gain some attention (comtypes is a pure Python, lightweight >> COM client and server framework, based on the ctypes Python FFI package.) >> >> I'll try to release a new version over the next days. >> >> However, I'm wondering what would be the correct list to discuss this package... >> >> - the python-win32 mailing list > > IMO most of COM knowledge is in python-win32 list. It's better not to > split due to python implementation details only. I think that this is a convincing argument. So, I will suggest to use the python-win32 mailing list for questions about comtypes. Thanks, Thomas From bjarnir at gmail.com Thu Dec 21 20:31:53 2006 From: bjarnir at gmail.com (Bjarni Ragnarsson) Date: Thu, 21 Dec 2006 19:31:53 +0000 Subject: [python-win32] Sessions and Unicode Message-ID: <938bcd6f0612211131y72a619f8u7ac4e43e045f12f7@mail.gmail.com> Hi Hope somone can help me. Using Python 2.5 and PyWin32-210 PythonScript .asp page on IIS and Windows XP I'm puzzled.... A Scripting.Dictionary is created and assigned to as Session variable in vb script. This dictionary is populated by reading a file. In the PythonScript this Session object is read an displayed. The foreign characters are all messed up and that's the problem of course. Now - the text items in the Session Object are reported to be of type Unicode (by the python type(x) function). The problem seems to be that the text Python is trying to interprete as Unicode is NOT Unicode at all. The original file is of type UTF-8 (I tried Windows-1252 too) and the code doesn't even read the file if I convert it to Unicode - returning an empty Dictionary. The same code seem to work fine on a Windows 2003 for some reason.... Anyone know what's going on and what to do? Best regards, Bjarni Ragnarsson From sidnei at enfoldsystems.com Fri Dec 22 01:24:30 2006 From: sidnei at enfoldsystems.com (Sidnei da Silva) Date: Thu, 21 Dec 2006 22:24:30 -0200 Subject: [python-win32] AMD64 support Message-ID: Hi there, I've spent some time today experimenting with building pywin32 for AMD64. That is, mostly the Py_ssize_t changes from PEP 353 and whatever else the compiler complained about. I've asked Mark for permission and made a 'AMD64' branch (apparently the first branch on this repository?!). The overall situation on the branch is the following: - It still builds with Python 2.4, meaning the changes are apparently backward compatible - It does not finish building with Python 2.5 AMD64, but it's pretty close. - I had to disable the building of 'axdebug', since it complained about a certain function ending with '64' which I could not figure how to declare. - The build fails when building the 'shell' module, with the error below. The process I'm using to build is: - Open the Platform SDK "Set Windows XP x64 Build Environment (Retail)" - 'set DISTUTILS_USE_SDK=1' - 'set INCLUDE=%INCLUDE%;C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include' (so it finds 'dxsound.h') - 'C:\Python25\python.exe setup.py build' The only thing that looks suspect on the output is that cl.exe from the SDK does not support the '/YX' switch, though maybe that doesn't matter. For reference, here's the diff between HEAD and the branch. https://houston.enfoldsystems.com/files/sidnei/pywin32-amd64.diff ******************************************************** C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\Win64\x86 \AMD64\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:\Program Files\Microsof t Platform SDK for Windows Server 2003 R2\lib\AMD64" /LIBPATH:c:\Python25\libs / LIBPATH:c:\Python25\PCBuild /LIBPATH:build\temp.win32-2.5\Release shell32.lib ol eaut32.lib ole32.lib /EXPORT:initshell build\temp.win32-2.5\Release\com/win32com ext/shell/src/PyIActiveDesktop.obj build\temp.win32-2.5\Release\com/win32comext/ shell/src/PyIAsyncOperation.obj build\temp.win32-2.5\Release\com/win32comext/she ll/src/PyIBrowserFrameOptions.obj build\temp.win32-2.5\Release\com/win32comext/s hell/src/PyIColumnProvider.obj build\temp.win32-2.5\Release\com/win32comext/shel l/src/PyIContextMenu.obj build\temp.win32-2.5\Release\com/win32comext/shell/src/ PyICopyHook.obj build\temp.win32-2.5\Release\com/win32comext/shell/src/PyIDeskBa nd.obj build\temp.win32-2.5\Release\com/win32comext/shell/src/PyIDockingWindow.o bj build\temp.win32-2.5\Release\com/win32comext/shell/src/PyIDropTargetHelper.ob j build\temp.win32-2.5\Release\com/win32comext/shell/src/PyIEnumIDList.obj build \temp.win32-2.5\Release\com/win32comext/shell/src/PyIExtractIcon.obj build\temp. win32-2.5\Release\com/win32comext/shell/src/PyIInputObject.obj build\temp.win32- 2.5\Release\com/win32comext/shell/src/PyIPersistFolder.obj build\temp.win32-2.5\ Release\com/win32comext/shell/src/PyIQueryAssociations.obj build\temp.win32-2.5\ Release\com/win32comext/shell/src/PyIShellBrowser.obj build\temp.win32-2.5\Relea se\com/win32comext/shell/src/PyIShellExtInit.obj build\temp.win32-2.5\Release\co m/win32comext/shell/src/PyIShellFolder.obj build\temp.win32-2.5\Release\com/win3 2comext/shell/src/PyIShellIcon.obj build\temp.win32-2.5\Release\com/win32comext/ shell/src/PyIShellIconOverlay.obj build\temp.win32-2.5\Release\com/win32comext/s hell/src/PyIShellIconOverlayIdentifier.obj build\temp.win32-2.5\Release\com/win3 2comext/shell/src/PyIShellIconOverlayManager.obj build\temp.win32-2.5\Release\co m/win32comext/shell/src/PyIShellLink.obj build\temp.win32-2.5\Release\com/win32c omext/shell/src/PyIShellLinkDataList.obj build\temp.win32-2.5\Release\com/win32c omext/shell/src/PyIShellView.obj build\temp.win32-2.5\Release\com/win32comext/sh ell/src/PyIUniformResourceLocator.obj build\temp.win32-2.5\Release\com/win32come xt/shell/src/shell.obj /OUT:build\lib.win32-2.5\win32comext/shell\shell.pyd /IMP LIB:build\temp.win32-2.5\Release\com/win32comext/shell/src\shell.lib /MACHINE:AM D64 /BASE:0x1e7d0000 shell.obj : warning LNK4197: export 'initshell' specified multiple times; using first specification Creating library build\temp.win32-2.5\Release\com/win32comext/shell/src\shell .lib and object build\temp.win32-2.5\Release\com/win32comext/shell/src\shell.exp PyIShellView.obj : error LNK2001: unresolved external symbol "int __cdecl PyObje ct_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned int * )" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) shell.obj : error LNK2001: unresolved external symbol "int __cdecl PyObject_AsPI DL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned int *)" (?Py Object_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIShellFolder.obj : error LNK2001: unresolved external symbol "int __cdecl PyOb ject_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned int *)" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIShellIcon.obj : error LNK2001: unresolved external symbol "int __cdecl PyObje ct_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned int * )" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIShellIconOverlay.obj : error LNK2001: unresolved external symbol "int __cdecl PyObject_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigne d int *)" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIShellLink.obj : error LNK2001: unresolved external symbol "int __cdecl PyObje ct_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned int * )" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIEnumIDList.obj : error LNK2019: unresolved external symbol "int __cdecl PyObj ect_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned int *)" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) referenced in function "protected: virtual long __cdecl PyGEnumIDList::Next(unsigned long,s truct _ITEMIDLIST __unaligned * *,unsigned long *)" (?Next at PyGEnumIDList@@MEAAJK PEAPEFAU_ITEMIDLIST@@PEAK at Z) PyIPersistFolder.obj : error LNK2001: unresolved external symbol "int __cdecl Py Object_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned i nt *)" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIShellBrowser.obj : error LNK2001: unresolved external symbol "int __cdecl PyO bject_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned in t *)" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) PyIShellExtInit.obj : error LNK2001: unresolved external symbol "int __cdecl PyO bject_AsPIDL(struct _object *,struct _ITEMIDLIST __unaligned * *,int,unsigned in t *)" (?PyObject_AsPIDL@@YAHPEAU_object@@PEAPEFAU_ITEMIDLIST@@HPEAI at Z) build\lib.win32-2.5\win32comext/shell\shell.pyd : fatal error LNK1120: 1 unresol ved externals error: command 'link.exe' failed with exit status 1120 ******************************************************** -- Sidnei da Silva Enfold Systems http://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 From gagsl-p32 at yahoo.com.ar Fri Dec 22 02:53:42 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 21 Dec 2006 22:53:42 -0300 Subject: [python-win32] Displaying contents of a file using PyWin In-Reply-To: <1166719897.867134.323000@80g2000cwy.googlegroups.com> References: <1166706266.025197.199620@79g2000cws.googlegroups.com> <1166716722.937893.297670@79g2000cws.googlegroups.com> <1166719897.867134.323000@80g2000cwy.googlegroups.com> Message-ID: <7.0.1.0.0.20061221224139.03e71a50@yahoo.com.ar> [Forwarded from python-list at ...] At Thursday 21/12/2006 13:51, MiguelS wrote: >import win32ui >from pywin.mfc import docview > >t = docview.DocTemplate() >t.OpenDocumentFile("d:/temp/music.log", True) > >This caused windows to close PythonWin. This appears to be a problem with pywin32. Using release 209 for Python 2.4 I get an Access Violation. Also I've noticed that this idiom: try: win32ui.GetApp().RemoveDocTemplate(template) except NameError: # haven't run this before - that's ok pass doesn't work anymore because RemoveDocTemplate raises a different exception now. -- Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From mhammond at skippinet.com.au Fri Dec 22 04:28:13 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 22 Dec 2006 14:28:13 +1100 Subject: [python-win32] Displaying contents of a file using PyWin In-Reply-To: <7.0.1.0.0.20061221224139.03e71a50@yahoo.com.ar> Message-ID: <024101c72579$371bd570$160a0a0a@enfoldsystems.local> Hi Gabriel, > [Forwarded from python-list at ...] > > At Thursday 21/12/2006 13:51, MiguelS wrote: > > >import win32ui > >from pywin.mfc import docview > > > >t = docview.DocTemplate() > >t.OpenDocumentFile("d:/temp/music.log", True) > > > >This caused windows to close PythonWin. > > This appears to be a problem with pywin32. > Using release 209 for Python 2.4 I get an Access Violation. It was attempting to set a Python error without the GIL held. I've fixed that - it now results in: win32ui: PyCDocument::OnOpenDocument handler does not exist. >>> Using: >>> t.OpenDocumentFile(None) Opens a document - I'm afraid I can't recall the MFC semantics here at the moment. > Also I've noticed that this idiom: > > try: > win32ui.GetApp().RemoveDocTemplate(template) > except NameError: > # haven't run this before - that's ok > pass > > doesn't work anymore because RemoveDocTemplate raises a different > exception now. I can't recall any change I made that would account for that. I'm assuming that the NameError comes from 'template' which is yet to be assigned - but in that case RemoveDocTemplate should not be called as the NameError happens before. I don't recall (and grep doesn't show) that pythonwin ever raises this exception. Mark From gagsl-p32 at yahoo.com.ar Fri Dec 22 07:11:08 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 22 Dec 2006 03:11:08 -0300 Subject: [python-win32] Displaying contents of a file using PyWin In-Reply-To: <024101c72579$371bd570$160a0a0a@enfoldsystems.local> References: <7.0.1.0.0.20061221224139.03e71a50@yahoo.com.ar> <024101c72579$371bd570$160a0a0a@enfoldsystems.local> Message-ID: <7.0.1.0.0.20061222025810.033a6c50@yahoo.com.ar> At Friday 22/12/2006 00:28, Mark Hammond wrote: > >import win32ui > > >from pywin.mfc import docview > > > > > >t = docview.DocTemplate() > > >t.OpenDocumentFile("d:/temp/music.log", True) > > > > > >This caused windows to close PythonWin. > > > > This appears to be a problem with pywin32. > > Using release 209 for Python 2.4 I get an Access Violation. > >It was attempting to set a Python error without the GIL held. I've fixed >that - it now results in: > >win32ui: PyCDocument::OnOpenDocument handler does not exist. > >>> Oh, thanks! >Using: > > >>> t.OpenDocumentFile(None) > >Opens a document - I'm afraid I can't recall the MFC semantics here at the >moment. I think one should inherit from docview.Document and write the OnOpenDocument handle, but I'm not sure either. I hope the OP has enough info to continue from here. > > Also I've noticed that this idiom: > > > > try: > > win32ui.GetApp().RemoveDocTemplate(template) > > except NameError: > > # haven't run this before - that's ok > > pass > > > > doesn't work anymore because RemoveDocTemplate raises a different > > exception now. > >I can't recall any change I made that would account for that. I'm assuming >that the NameError comes from 'template' which is yet to be assigned - but >in that case RemoveDocTemplate should not be called as the NameError happens >before. I don't recall (and grep doesn't show) that pythonwin ever raises >this exception. It is used in 4 scripts inside pythonwin\pywin\framework. And can be found on your own book, chapter 20... -- Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From SGamble at madera-county.com Wed Dec 27 20:34:34 2006 From: SGamble at madera-county.com (Stacey Gamble) Date: Wed, 27 Dec 2006 11:34:34 -0800 Subject: [python-win32] Getting Started Message-ID: I'm a new Python user, trying to use the geoprocessing dispatch object. I get an error message as soon as I import the win32com.client. See below. What am I doing wrong? >>> Unhandled exception while debugging... Traceback (most recent call last): File "C:\Python21\win32com\__init__.py", line 32, in SetupEnvironment __path__.append( win32api.RegQueryValue(key, "Extensions" )) error: (2, 'RegQueryValue', 'The system cannot find the file specified.') [Dbg]>>> Stacey W. Gamble Information Systems Supervisor County of Madera Information Technology Department 216 West 6th Street Madera, CA 93637 Voice: (559) 661-5267 Fax: (559) 675-4965 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061227/50c83d74/attachment.html From timr at probo.com Wed Dec 27 21:51:05 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 27 Dec 2006 12:51:05 -0800 Subject: [python-win32] Getting Started In-Reply-To: References: Message-ID: <4592DCB9.4080508@probo.com> Stacey Gamble wrote: > > I?m a new Python user, trying to use the geoprocessing dispatch > object. I get an error message as soon as I import the > win32com.client. See below. What am I doing wrong? > > >>> Unhandled exception while debugging... > > Traceback (most recent call last): > > File "C:\Python21\win32com\__init__.py", line 32, in SetupEnvironment > > __path__.append( win32api.RegQueryValue(key, "Extensions" )) > > error: (2, 'RegQueryValue', 'The system cannot find the file specified.') > > [Dbg]>>> > What version of the pywin32 stuff did you install, and where did you get it? This key is optional, and this read should be wrapped in a try/except block. Python 2.1 is very, very old. You would be much better served by upgrading to 2.4 -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From eric.powell at srs.gov Wed Dec 27 21:54:22 2006 From: eric.powell at srs.gov (eric.powell at srs.gov) Date: Wed, 27 Dec 2006 15:54:22 -0500 Subject: [python-win32] Getting Started In-Reply-To: <4592DCB9.4080508@probo.com> Message-ID: Tim- That is the version ESRI shipped with ArcGIS 9.1. I do not know what version they ship with 9.2 (as I am not in the GIS business currently :( ) However, the newer versions worked fine with the ESRI tools (in 9.1 at least) if the users knew to upgrade. Eric Eric B. Powell BSRI Electronic Aids (803)208-6207 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061227/9f7e7d16/attachment.htm From SGamble at madera-county.com Wed Dec 27 22:16:36 2006 From: SGamble at madera-county.com (Stacey Gamble) Date: Wed, 27 Dec 2006 13:16:36 -0800 Subject: [python-win32] Getting Started Message-ID: Hi Tim: I've just upgraded my ArcView to 9.2 with Python version 2.4. I'm hoping that might fix my problem. Thanks for responding. SWG -----Original Message----- From: python-win32-bounces+sgamble=madera-county.com at python.org [mailto:python-win32-bounces+sgamble=madera-county.com at python.org] On Behalf Of Tim Roberts Sent: Wednesday, December 27, 2006 12:51 PM To: Python-Win32 List Subject: Re: [python-win32] Getting Started Stacey Gamble wrote: > > I'm a new Python user, trying to use the geoprocessing dispatch > object. I get an error message as soon as I import the > win32com.client. See below. What am I doing wrong? > > >>> Unhandled exception while debugging... > > Traceback (most recent call last): > > File "C:\Python21\win32com\__init__.py", line 32, in SetupEnvironment > > __path__.append( win32api.RegQueryValue(key, "Extensions" )) > > error: (2, 'RegQueryValue', 'The system cannot find the file specified.') > > [Dbg]>>> > What version of the pywin32 stuff did you install, and where did you get it? This key is optional, and this read should be wrapped in a try/except block. Python 2.1 is very, very old. You would be much better served by upgrading to 2.4 -- 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 bgailer at alum.rpi.edu Fri Dec 29 01:20:16 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 28 Dec 2006 16:20:16 -0800 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' Message-ID: <45945F40.4080307@alum.rpi.edu> I'm running this under my Apache2triad mod_python installation. Yesterday it was working. Today it is not. In the Apache config mptest.py is defined as the request handler. When called via an HTTP request I get the following: Traceback (most recent call last): File "H:\Python24\Lib\site-packages\mod_python\apache.py", line 299, in HandlerDispatch result = object(req) File "H:/apache2triad/htdocs/output/mptest.py", line 45, in handler if actHandler: actHandler(req, parameters) File "H:/apache2triad/htdocs/output/mptest.py", line 52, in search connect() File "H:/apache2triad/htdocs/output/mptest.py", line 26, in connect conn = win32com.client.Dispatch("ADODB.Connection") File "H:\Python24\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "H:\Python24\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "H:\Python24\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221008, 'CoInitialize has not been called.', None, None) Trying the same thing in the PythonWin interactive window - it works just fine. -- Bob Gailer 510-978-4454 From rwupole at msn.com Fri Dec 29 02:34:51 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 28 Dec 2006 20:34:51 -0500 Subject: [python-win32] Re: Dispatch error 'CoInitialize has not been called' Message-ID: Bob Gailer wrote: > I'm running this under my Apache2triad mod_python installation. > Yesterday it was working. Today it is not. > In the Apache config mptest.py is defined as the request handler. When > called via an HTTP request I get the following: > > Traceback (most recent call last): > > File "H:\Python24\Lib\site-packages\mod_python\apache.py", line 299, > in HandlerDispatch > result = object(req) > > File "H:/apache2triad/htdocs/output/mptest.py", line 45, in handler > if actHandler: actHandler(req, parameters) > > File "H:/apache2triad/htdocs/output/mptest.py", line 52, in search > connect() > > File "H:/apache2triad/htdocs/output/mptest.py", line 26, in connect > conn = win32com.client.Dispatch("ADODB.Connection") > > File "H:\Python24\lib\site-packages\win32com\client\__init__.py", line > 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > > File "H:\Python24\lib\site-packages\win32com\client\dynamic.py", line > 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > > File "H:\Python24\lib\site-packages\win32com\client\dynamic.py", line > 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > > com_error: (-2147221008, 'CoInitialize has not been called.', None, None) > > Trying the same thing in the PythonWin interactive window - it works > just fine. > If it's running in a thread, you need to call pythoncom.CoInitialize yourself. Roger From bgailer at alum.rpi.edu Fri Dec 29 05:47:57 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 28 Dec 2006 20:47:57 -0800 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: References: Message-ID: <45949DFD.40504@alum.rpi.edu> Roger Upole wrote: > Bob Gailer wrote: > >> I'm running this under my Apache2triad mod_python installation. >> Yesterday it was working. Today it is not. >> In the Apache config mptest.py is defined as the request handler. When >> called via an HTTP request I get the following: >> >> Traceback (most recent call last): >> >> File "H:\Python24\Lib\site-packages\mod_python\apache.py", line 299, >> in HandlerDispatch >> result = object(req) >> >> File "H:/apache2triad/htdocs/output/mptest.py", line 45, in handler >> if actHandler: actHandler(req, parameters) >> >> File "H:/apache2triad/htdocs/output/mptest.py", line 52, in search >> connect() >> >> File "H:/apache2triad/htdocs/output/mptest.py", line 26, in connect >> conn = win32com.client.Dispatch("ADODB.Connection") >> >> File "H:\Python24\lib\site-packages\win32com\client\__init__.py", line >> 95, in Dispatch >> dispatch, userName = >> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) >> >> File "H:\Python24\lib\site-packages\win32com\client\dynamic.py", line >> 98, in _GetGoodDispatchAndUserName >> return (_GetGoodDispatch(IDispatch, clsctx), userName) >> >> File "H:\Python24\lib\site-packages\win32com\client\dynamic.py", line >> 78, in _GetGoodDispatch >> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, >> pythoncom.IID_IDispatch) >> >> com_error: (-2147221008, 'CoInitialize has not been called.', None, None) >> >> Trying the same thing in the PythonWin interactive window - it works >> just fine. >> >> > > If it's running in a thread, you need to call pythoncom.CoInitialize yourself. > OK. I don't know whether its running in a thread. I made no changes that I'm aware of that would cause the change in behavior. I will add the call to pythoncom.CoInitialize. I am not familiar with this method. .... time passes .... OK I added it and now it works. Thanks. -- Bob Gailer 510-978-4454 From Tim.Golden at viacom-outdoor.co.uk Fri Dec 29 10:44:52 2006 From: Tim.Golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 29 Dec 2006 09:44:52 -0000 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: <45949DFD.40504@alum.rpi.edu> Message-ID: [Bob Gailer] > OK. I don't know whether its running in a thread. I made no > changes that I'm aware of that would cause the change in > behavior. I will add the call to pythoncom.CoInitialize. I am > not familiar with this method. This is one of those gotcha's of Win32 COM programming; you can be happily using some code which runs fine. You then drop it into a [web server / service / scheduled job] and lo! you're now running in a thread. I'm not sure (and perhaps someone can advise) whether there's any harm in *always* calling CoInitialize! TJG Tim Golden Senior Analyst Programmer -------------------------------------------------------- Viacom Outdoor Ltd, Camden Wharf, 28 Jamestown Road, London, NW1 7BY T: 020 7482 3000 F: 020 7267 4944 Email: Tim.Golden at viacom-outdoor.co.uk www.viacom-outdoor.co.uk The contents of this e-mail are confidential to the ordinary user of the e-mail address to which it was addressed, and may also be privileged. If you are not the addressee of this e-mail you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error, please e-mail the sender by replying to this message. Viacom Outdoor Ltd reserves the right to monitor e-mail communications from external/internal sources for the purposes of ensuring correct and appropriate use of Viacom Outdoor facilities. ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From bgailer at alum.rpi.edu Fri Dec 29 20:29:27 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 29 Dec 2006 11:29:27 -0800 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: References: Message-ID: <45956C97.6070700@alum.rpi.edu> Tim Golden wrote: > [Bob Gailer] > >> OK. I don't know whether its running in a thread. I made no >> changes that I'm aware of that would cause the change in >> behavior. I will add the call to pythoncom.CoInitialize. I am >> not familiar with this method. >> > > This is one of those gotcha's of Win32 COM programming; > you can be happily using some code which runs fine. You > then drop it into a [web server / service / scheduled job] > and lo! you're now running in a thread. > Yeah, but when I said it was working, it was working in the server! Wednesday AM just fine. Wednesday afternoon suddenly not working fine. I swear I didn't change anything! Is there some way my program can introspect? to see if it is in a thread? > I'm not sure (and perhaps someone can advise) whether there's > any harm in *always* calling CoInitialize! -- Bob Gailer 510-978-4454 From mail at timgolden.me.uk Fri Dec 29 21:17:08 2006 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 29 Dec 2006 20:17:08 +0000 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: <45956C97.6070700@alum.rpi.edu> References: <45956C97.6070700@alum.rpi.edu> Message-ID: <459577C4.60409@timgolden.me.uk> >> [Bob Gailer] > Yeah, but when I said it was working, it was working in the server! > Wednesday AM just fine. Wednesday afternoon suddenly not working fine. I > swear I didn't change anything! > > Is there some way my program can introspect? to see if it is in a thread? It's a bit clunky, but I think you can do this: import threading import pythoncom if threading.currentThread ().getName () <> 'MainThread': pythoncom.CoInitialize () TJG From rwupole at msn.com Fri Dec 29 22:32:39 2006 From: rwupole at msn.com (Roger Upole) Date: Fri, 29 Dec 2006 16:32:39 -0500 Subject: [python-win32] Re: Dispatch error 'CoInitialize has not been called' Message-ID: Bob Gailer wrote: > Tim Golden wrote: >> [Bob Gailer] >> >>> OK. I don't know whether its running in a thread. I made no >>> changes that I'm aware of that would cause the change in >>> behavior. I will add the call to pythoncom.CoInitialize. I am >>> not familiar with this method. >>> >> >> This is one of those gotcha's of Win32 COM programming; >> you can be happily using some code which runs fine. You >> then drop it into a [web server / service / scheduled job] >> and lo! you're now running in a thread. >> > Yeah, but when I said it was working, it was working in the server! > Wednesday AM just fine. Wednesday afternoon suddenly not working fine. I > swear I didn't change anything! > > Is there some way my program can introspect? to see if it is in a thread? > I'm not sure (and perhaps someone can advise) whether there's > any harm in *always* calling CoInitialize! Multiple calls to CoInitialize don't hurt anything. However (and I should have mentioned this before) you also need to call CoUninitialize yourself at the end of the thread. Roger From bgailer at alum.rpi.edu Fri Dec 29 23:00:29 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 29 Dec 2006 14:00:29 -0800 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: <459577C4.60409@timgolden.me.uk> References: <45956C97.6070700@alum.rpi.edu> <459577C4.60409@timgolden.me.uk> Message-ID: <45958FFD.9090404@alum.rpi.edu> Tim Golden wrote: >>> [Bob Gailer] >>> >> Yeah, but when I said it was working, it was working in the server! >> Wednesday AM just fine. Wednesday afternoon suddenly not working fine. I >> swear I didn't change anything! >> >> Is there some way my program can introspect? to see if it is in a thread? >> > > It's a bit clunky, but I think you can do this: > > > import threading > import pythoncom > > if threading.currentThread ().getName () <> 'MainThread': > pythoncom.CoInitialize () > I had my code return threading.currentThread().getName() and it is "H:\apache2triad". I'm not sure what that tells me, except that it is in a thread. I think I have a lot to learn about Apache and mod_python. > -- Bob Gailer 510-978-4454 From bgailer at alum.rpi.edu Fri Dec 29 23:02:24 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 29 Dec 2006 14:02:24 -0800 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: References: Message-ID: <45959070.7040908@alum.rpi.edu> Roger Upole wrote: > Bob Gailer wrote: > >> Tim Golden wrote: >> >>> [Bob Gailer] >>> >>> >>>> OK. I don't know whether its running in a thread. I made no >>>> changes that I'm aware of that would cause the change in >>>> behavior. I will add the call to pythoncom.CoInitialize. I am >>>> not familiar with this method. >>>> >>>> >>> This is one of those gotcha's of Win32 COM programming; >>> you can be happily using some code which runs fine. You >>> then drop it into a [web server / service / scheduled job] >>> and lo! you're now running in a thread. >>> >>> >> Yeah, but when I said it was working, it was working in the server! >> Wednesday AM just fine. Wednesday afternoon suddenly not working fine. I >> swear I didn't change anything! >> >> Is there some way my program can introspect? to see if it is in a thread? >> I'm not sure (and perhaps someone can advise) whether there's >> any harm in *always* calling CoInitialize! >> > > Multiple calls to CoInitialize don't hurt anything. However (and I should have > mentioned this before) you also need to call CoUninitialize yourself at the end > of the thread. > As I mentioned in my response to Tim, the thread name is "H:\apache2triad". Since this is a long-running python instance I'm not sure how to tell that the thread has ended. Is there magic to detect that? And what happens if CoUninitialize does not get called? -- Bob Gailer 510-978-4454 From rwupole at msn.com Sun Dec 31 18:50:56 2006 From: rwupole at msn.com (Roger Upole) Date: Sun, 31 Dec 2006 12:50:56 -0500 Subject: [python-win32] Re: Dispatch error 'CoInitialize has not been called' Message-ID: Bob Gailer wrote: > Roger Upole wrote: >> Bob Gailer wrote: >> >>> Tim Golden wrote: >>> >>>> [Bob Gailer] >>>> >>>> >>>>> OK. I don't know whether its running in a thread. I made no >>>>> changes that I'm aware of that would cause the change in >>>>> behavior. I will add the call to pythoncom.CoInitialize. I am >>>>> not familiar with this method. >>>>> >>>>> >>>> This is one of those gotcha's of Win32 COM programming; >>>> you can be happily using some code which runs fine. You >>>> then drop it into a [web server / service / scheduled job] >>>> and lo! you're now running in a thread. >>>> >>>> >>> Yeah, but when I said it was working, it was working in the server! >>> Wednesday AM just fine. Wednesday afternoon suddenly not working fine. I >>> swear I didn't change anything! >>> >>> Is there some way my program can introspect? to see if it is in a thread? >>> I'm not sure (and perhaps someone can advise) whether there's >>> any harm in *always* calling CoInitialize! >>> >> >> Multiple calls to CoInitialize don't hurt anything. However (and I should have >> mentioned this before) you also need to call CoUninitialize yourself at the end >> of the thread. >> > As I mentioned in my response to Tim, the thread name is > "H:\apache2triad". Since this is a long-running python instance I'm not > sure how to tell that the thread has ended. Is there magic to detect > that? And what happens if CoUninitialize does not get called? If CoUninitialize doesn't get called for each call to CoInitialize, you can leak memory. You should be fine if you call CoInit before you start, and CoUninit when you're done processing. Roger