From caizhenkun19850809 at yahoo.com.cn Wed Jan 2 03:43:36 2013 From: caizhenkun19850809 at yahoo.com.cn (=?utf-8?B?6ZyH5Z2kIOiUoQ==?=) Date: Wed, 2 Jan 2013 10:43:36 +0800 (CST) Subject: [python-win32] The program passes on Win7 but fails on Win8 Message-ID: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> Hi, Guys. I wrote the following program. It could not pass on Win8, but it can pass on Win7. It will try to simulate the action to click the Next button on an existing dialog (I use JDK installation dialog). I believe the issue comes from the statement 'win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, win32con.BN_CLICKED, hButton)'. import win32gui import win32con import win32api print "abc" hWindow = win32gui.FindWindow('MsiDialogCloseClass', None) if hWindow <> 0: ??? print hWindow ??? hButton = win32gui.FindWindowEx(hWindow, 0, 'Button', '&Next >') ??? if hButton <> 0: ??????? print hButton ? ?? ?? win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, win32con.BN_CLICKED, hButton) ??? else: ??????? print "ghi" else: ??? print "def" However, I wrote another program to validate the SendMessage function. It will try to add some texts into an existing Notepad program. But it can get passed on both Win7 and Win8. print "abc" hWindow2 = win32gui.FindWindow('Notepad', None) if hWindow2 <> 0: ??? print hWindow2 ??? hEdit = win32gui.FindWindowEx(hWindow2, 0, 'Edit', None) ??? if hEdit <> 0: ??????? print hEdit ??????? win32gui.SendMessage(hEdit, win32con.WM_SETTEXT, None, 'hello, czk') ??? else: ??????? print "ghi" else: ??? print "def" So I wonder whether it is caused by the reason that win32gui.SendMessage only partially supports Win8? As in my examples, you can see win32gui.SendMessage with parameter win32con.WM_SETTEXT is OK while with parameters win32con.WM_COMMAND and win32con.BN_CLICKED are not supporting win8. It's only my guessing. If anyone found I had typed some code wrong, please help to point out. Thanks and Best Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From alimakawi at gmail.com Wed Jan 2 06:39:56 2013 From: alimakawi at gmail.com (Ali . Mohamed Makawii) Date: Wed, 2 Jan 2013 08:39:56 +0300 Subject: [python-win32] Windows 7 Message-ID: Ihave windows 7 help me how to use python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jan 2 18:33:07 2013 From: timr at probo.com (Tim Roberts) Date: Wed, 2 Jan 2013 09:33:07 -0800 Subject: [python-win32] The program passes on Win7 but fails on Win8 In-Reply-To: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> References: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> Message-ID: <50E46F53.6030205@probo.com> ?? ? wrote: > > I wrote the following program. It could not pass on Win8, but it can > pass on Win7. > It will try to simulate the action to click the Next button on an > existing dialog (I use JDK installation dialog). > I believe the issue comes from the statement > 'win32gui.SendMessage(win32gui.GetParent(hButton), > win32con.WM_COMMAND, win32con.BN_CLICKED, hButton)'. Your call is incorrect. The WPARAM for BN_CLICKED is supposed to have the button's control ID in the low word, and the notification code in the high word. So, you should have: win32gui.SendMessage( win32gui.GetParent(hButton, win32con.WM_COMMAND, (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton), hButton ); What DOES happen on Win 8? Does it simply do nothing? Does the app crash? Do you see valid handles for both the hWindow and the hButton? Are you sure the dialog has the same structure in Win 8 that it did in Win 7? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jan 2 18:33:30 2013 From: timr at probo.com (Tim Roberts) Date: Wed, 2 Jan 2013 09:33:30 -0800 Subject: [python-win32] Windows 7 In-Reply-To: References: Message-ID: <50E46F6A.2010501@probo.com> Ali . Mohamed Makawii wrote: > Ihave windows 7 help me how to use python-win32 What have you tried? What works, what doesn't? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jan 2 18:36:17 2013 From: timr at probo.com (Tim Roberts) Date: Wed, 2 Jan 2013 09:36:17 -0800 Subject: [python-win32] The program passes on Win7 but fails on Win8 In-Reply-To: <50E46F53.6030205@probo.com> References: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> <50E46F53.6030205@probo.com> Message-ID: <50E47011.9070900@probo.com> Tim Roberts wrote: > ?? ? wrote: >> I wrote the following program. It could not pass on Win8, but it can >> pass on Win7. >> It will try to simulate the action to click the Next button on an >> existing dialog (I use JDK installation dialog). >> I believe the issue comes from the statement >> 'win32gui.SendMessage(win32gui.GetParent(hButton), >> win32con.WM_COMMAND, win32con.BN_CLICKED, hButton)'. > Your call is incorrect. The WPARAM for BN_CLICKED is supposed to have > the button's control ID in the low word, and the notification code in > the high word. So, you should have: > > win32gui.SendMessage( win32gui.GetParent(hButton, win32con.WM_COMMAND, > (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton), > hButton ); (Whoops, there's a missing parenthesis and an extra semicolon there:) win32gui.SendMessage( win32gui.GetParent(hButton), win32con.WM_COMMAND, (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton), hButton ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From caizhenkun19850809 at yahoo.com.cn Thu Jan 3 16:35:14 2013 From: caizhenkun19850809 at yahoo.com.cn (=?utf-8?B?6ZyH5Z2kIOiUoQ==?=) Date: Thu, 3 Jan 2013 23:35:14 +0800 (CST) Subject: [python-win32] =?utf-8?b?5Zue5aSN77yaICBUaGUgcHJvZ3JhbSBwYXNzZXMg?= =?utf-8?q?on_Win7_but_fails_on_Win8?= In-Reply-To: <50E46F53.6030205@probo.com> References: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> <50E46F53.6030205@probo.com> Message-ID: <1357227314.11629.YahooMailNeo@web15205.mail.cnb.yahoo.com> Thanks for your reply. For the program I have written: print "abc" hWindow = win32gui.FindWindow('MsiDialogCloseClass', None) if hWindow <> 0: ??? print hWindow ??? hButton = win32gui.FindWindowEx(hWindow, 0, 'Button', '&Next >') ??? if hButton <> 0: ??????? print hButton ? ?? ?? win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, win32con.BN_CLICKED, hButton) ??? else: ??????? print "ghi" else: ??? print "def" The hWindow and hButton can both be printed out and they are both not 0. The application does not crash but the Next button click action is not triggered. So the problem is: the handles could be found but the click button message is not successfully sent in Win8 (which could be successful in Win7). I use Spy++ to check the controls of the dialog. I think they are same in WIn7 and Win8. (What I use is the JDK installation file with version 1.6.0_37. A Next button will display during the installation process. What I want to do is to automate the installation steps.) ________________________________ ???? Tim Roberts ???? Python-Win32 List ????? 2013?1?3?, ???, 1:33 ?? ??: Re: [python-win32] The program passes on Win7 but fails on Win8 ?? ? wrote: > > I wrote the following program. It could not pass on Win8, but it can > pass on Win7. > It will try to simulate the action to click the Next button on an > existing dialog (I use JDK installation dialog). > I believe the issue comes from the statement > 'win32gui.SendMessage(win32gui.GetParent(hButton), > win32con.WM_COMMAND, win32con.BN_CLICKED, hButton)'. Your call is incorrect.? The WPARAM for BN_CLICKED is supposed to have the button's control ID in the low word, and the notification code in the high word.? So, you should have: ? ? win32gui.SendMessage( win32gui.GetParent(hButton, win32con.WM_COMMAND, ? ? ? ? (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton), hButton ); What DOES happen on Win 8?? Does it simply do nothing?? Does the app crash?? Do you see valid handles for both the hWindow and the hButton? Are you sure the dialog has the same structure in Win 8 that it did in Win 7? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Jan 3 18:55:06 2013 From: timr at probo.com (Tim Roberts) Date: Thu, 3 Jan 2013 09:55:06 -0800 Subject: [python-win32] =?utf-8?b?5Zue5aSN77yaICBUaGUgcHJvZ3JhbSBwYXNzZXMg?= =?utf-8?q?on_Win7_but_fails_on_Win8?= In-Reply-To: <1357227314.11629.YahooMailNeo@web15205.mail.cnb.yahoo.com> References: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> <50E46F53.6030205@probo.com> <1357227314.11629.YahooMailNeo@web15205.mail.cnb.yahoo.com> Message-ID: <50E5C5FA.10105@probo.com> ?? ? wrote: > Thanks for your reply. > For the program I have written: > print "abc" > hWindow = win32gui.FindWindow('MsiDialogCloseClass', None) > if hWindow <> 0: > print hWindow > hButton = win32gui.FindWindowEx(hWindow, 0, 'Button', '&Next >') > if hButton <> 0: > print hButton > win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, win32con.BN_CLICKED, hButton) > else: > print "ghi" > else: > print "def" > The hWindow and hButton can both be printed out and they are both not 0. > The application does not crash but the Next button click action is not > triggered. No, of course not, because the SendMessage call is still wrong. Did you even read my reply? The third parameter is wrong. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From caizhenkun19850809 at yahoo.com.cn Fri Jan 4 06:43:06 2013 From: caizhenkun19850809 at yahoo.com.cn (=?utf-8?B?6ZyH5Z2kIOiUoQ==?=) Date: Fri, 4 Jan 2013 13:43:06 +0800 (CST) Subject: [python-win32] =?utf-8?b?5Zue5aSN77yaICDlm57lpI3vvJogIFRoZSBwcm9n?= =?utf-8?q?ram_passes_on_Win7_but_fails_on_Win8?= In-Reply-To: <50E5C5FA.10105@probo.com> References: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> <50E46F53.6030205@probo.com> <1357227314.11629.YahooMailNeo@web15205.mail.cnb.yahoo.com> <50E5C5FA.10105@probo.com> Message-ID: <1357278186.46892.YahooMailNeo@web15208.mail.cnb.yahoo.com> I have changed the third parameter, but it still did not work on Win8. print "abc" hWindow = win32gui.FindWindow('MsiDialogCloseClass', None) if hWindow <> 0: ??? print hWindow ??? hButton = win32gui.FindWindowEx(hWindow, 0, 'Button', '&Next >') ??? if hButton <> 0: ??????? print hButton ??????? win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton), hButton) ??? else: ??????? print "ghi" else: ??? print "def" Output: abc 131870 131888 (The tested dialog used is the installation file for JDK 1.6.0_37 jdk-6u37-windows-i586.exe from http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u37-oth-JPR.) ________________________________ ???? Tim Roberts ???? Python-Win32 List ????? 2013?1?4?, ???, 1:55 ?? ??: Re: [python-win32] ??? The program passes on Win7 but fails on Win8 ?? ? wrote: > Thanks for your reply. > For the program I have written: > print "abc" > hWindow = win32gui.FindWindow('MsiDialogCloseClass', None) > if hWindow <> 0: >? ? print hWindow >? ? hButton = win32gui.FindWindowEx(hWindow, 0, 'Button', '&Next >') >? ? if hButton <> 0: >? ? ? ? print hButton >? ? ? ? win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, win32con.BN_CLICKED, hButton) >? ? else: >? ? ? ? print "ghi" > else: >? ? print "def" > The hWindow and hButton can both be printed out and they are both not 0. > The application does not crash but the Next button click action is not > triggered. No, of course not, because the SendMessage call is still wrong.? Did you even read my reply?? The third parameter is wrong. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jan 4 19:00:33 2013 From: timr at probo.com (Tim Roberts) Date: Fri, 4 Jan 2013 10:00:33 -0800 Subject: [python-win32] =?utf-8?b?5Zue5aSN77yaICDlm57lpI3vvJogIFRoZSBwcm9n?= =?utf-8?q?ram_passes_on_Win7_but_fails_on_Win8?= In-Reply-To: <1357278186.46892.YahooMailNeo@web15208.mail.cnb.yahoo.com> References: <1357094616.32758.YahooMailNeo@web15208.mail.cnb.yahoo.com> <50E46F53.6030205@probo.com> <1357227314.11629.YahooMailNeo@web15205.mail.cnb.yahoo.com> <50E5C5FA.10105@probo.com> <1357278186.46892.YahooMailNeo@web15208.mail.cnb.yahoo.com> Message-ID: <50E718C1.4070801@probo.com> ?? ? wrote: > I have changed the third parameter, but it still did not work on Win8. > > ... > win32gui.SendMessage(win32gui.GetParent(hButton), > win32con.WM_COMMAND, (win32con.BN_CLICKED << 16) | > win32gui.GetDlgCtrlID(hButton), hButton) > ... > Output: > abc > 131870 > 131888 I don't know. It looks OK to me. Have you tried this from a C program to see if the results are any different? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tomthemighty at googlemail.com Thu Jan 10 14:00:29 2013 From: tomthemighty at googlemail.com (Tom Bowles) Date: Thu, 10 Jan 2013 13:00:29 +0000 Subject: [python-win32] Python Finalisation Message-ID: Hi, I have a question regarding python finalisation when using pywin32. The details are at http://stackoverflow.com/questions/14257654/how-should-i-or-should-i-finalize-python-in-the-presence-of-pywin32. I can reproduce the question here if preferred, but there's a lot of formatting and I'm posting this from a phone. Hope the stackoverflow link is acceptable. Thanks, Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From shellc00de at gmail.com Thu Jan 10 17:30:11 2013 From: shellc00de at gmail.com (Shell Code) Date: Thu, 10 Jan 2013 17:30:11 +0100 Subject: [python-win32] Problem with python 3.3.0 Message-ID: Hi,i want to submit an error in python for windows version 3.3.0.When i try to run simple code (exp: print "Hello";) .Interpreter returns me a message box wich said : (Invalid sytnax!) Now i downloaded version 2.7.3 and code works perfect now.Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Thu Jan 10 18:13:49 2013 From: aahz at pythoncraft.com (Aahz) Date: Thu, 10 Jan 2013 09:13:49 -0800 Subject: [python-win32] Problem with python 3.3.0 In-Reply-To: References: Message-ID: <20130110171349.GA3126@panix.com> On Thu, Jan 10, 2013, Shell Code wrote: > > Hi,i want to submit an error in python for windows version 3.3.0.When i try > to run simple code (exp: print "Hello";) .Interpreter returns me a message > box wich said : (Invalid sytnax!) Now i downloaded version 2.7.3 and code > works perfect now.Thanks http://docs.python.org/3/whatsnew/3.0.html#common-stumbling-blocks -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. From aahz at pythoncraft.com Thu Jan 10 18:15:00 2013 From: aahz at pythoncraft.com (Aahz) Date: Thu, 10 Jan 2013 09:15:00 -0800 Subject: [python-win32] Python Finalisation In-Reply-To: References: Message-ID: <20130110171500.GB3126@panix.com> On Thu, Jan 10, 2013, Tom Bowles wrote: > > Hi, I have a question regarding python finalisation when using pywin32. > The details are at > http://stackoverflow.com/questions/14257654/how-should-i-or-should-i-finalize-python-in-the-presence-of-pywin32. > I can reproduce the question here if preferred, but there's a lot of > formatting and I'm posting this from a phone. Hope the stackoverflow link > is acceptable. I'm certainly not looking at Stackoverflow, and it disrupts the archives of this list. Please repeat your full question here. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. From timr at probo.com Thu Jan 10 19:02:26 2013 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Jan 2013 10:02:26 -0800 Subject: [python-win32] Problem with python 3.3.0 In-Reply-To: References: Message-ID: <50EF0232.4050804@probo.com> Shell Code wrote: > Hi,i want to submit an error in python for windows version 3.3.0.When > i try to run simple code (exp: print "Hello";) .Interpreter returns me > a message box wich said : (Invalid sytnax!) Now i downloaded version > 2.7.3 and code works perfect now. Allow me to offer you some unsolicited advice. When you are just starting out, NEVER assume that the problem is a bug in your tools. The "print" statement/function is absolutely fundamental to Python, and Python has a huge user base. If it were broken, it would have been addressed long before you saw it. You do know that the semicolon you have there ( print "Hello"; ) is not needed in Python, right? This is not C. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tomthemighty at googlemail.com Thu Jan 10 19:48:24 2013 From: tomthemighty at googlemail.com (Tom Bowles) Date: Thu, 10 Jan 2013 18:48:24 +0000 Subject: [python-win32] Python Finalisation In-Reply-To: <20130110171500.GB3126@panix.com> References: <20130110171500.GB3126@panix.com> Message-ID: On 10 January 2013 17:15, Aahz wrote: > On Thu, Jan 10, 2013, Tom Bowles wrote: > > > > Hi, I have a question regarding python finalisation when using pywin32. > > The details are at > > > http://stackoverflow.com/questions/14257654/how-should-i-or-should-i-finalize-python-in-the-presence-of-pywin32 > . > > I can reproduce the question here if preferred, but there's a lot of > > formatting and I'm posting this from a phone. Hope the stackoverflow link > > is acceptable. > > I'm certainly not looking at Stackoverflow, and it disrupts the archives > of this list. Please repeat your full question here. > -- > Aahz (aahz at pythoncraft.com) <*> > http://www.pythoncraft.com/ > > Weinberg's Second Law: If builders built buildings the way programmers > wrote > programs, then the first woodpecker that came along would destroy > civilization. > Sure. For a more specialist audience than SO it boils down to: 1. Should I call PyWinGlobals_Free() before calling Py_Finalize()? If I don't I get errors, which I can give more detail about if you want. 2. Why does pycom's dllmain.cpp contain a comment implying that it is not safe to "ever" finalize python "in the COM world". 3. What happened to the pycom-dev archive? pythonpros.com, which all the links to it I can find point to, appears to be a sedo parking thing. Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From fjanoos at yahoo.com Mon Jan 14 21:28:26 2013 From: fjanoos at yahoo.com (FJ) Date: Mon, 14 Jan 2013 12:28:26 -0800 (PST) Subject: [python-win32] Access to PI-db from Python : In-Reply-To: References: Message-ID: <1358195306.88731.YahooMailNeo@web165003.mail.bf1.yahoo.com> Hello, ? ? I've been write some code to access a PI system (OSI soft) database from Python code and I keep running into a "Python instance can not be converted to a COM object" error everytime I try to access a method on the PI COM objects. ? Specifically, I followed the example from http://oracleabc.com/b/archives/2850?as : ? ?importwin32com.clientimportpythoncomimporttime ?pi_sdk pi_time_start =win32com.client.Dispatch('PISDK.PISDK')=win32com.client.Dispatch('PITimeServer.PITime')pi_time_end =win32com.client.Dispatch('PITimeServer.PITime')win32com.client.Dispatch('PISDKCommon.NamedValues')pi_server =pi_sdk.Servers('myservername')# PI server or collective name pi_server.Open();pi_pt pi_data =pi_pt.Data; ?print# This read only property returns the most recent value stored on the server for the associated PIPoint as a PIValue object.pi_pt.Data.Snapshot(); ? ? ? ? >> 0.0756051763892 ?# PIData methods returns a reference to a single PIValue object from the server for the associated PIPoint based on the passed time and mode. Accepts a VT_BSTR argumentpi_data ?> --------------------------------------------------------------------------- > TypeError???????????????????????????????? Traceback (most recent call last) > file://pythonapplication1/%3Cipython-input-34-a8bfc6a08db7> in () > ----> 1 pi_data.ArcValue("10-JAN-2013 1:00:00.") > C:\ProgramData\Python27\lib\site-packages\win32com\gen_py\0EE075CE-8C31-11D1-BD73-0060B0290178x0x1x1.pyc in > ArcValue(sel > f, TimeStamp, Mode, asynchStatus) >??? 8039???????????????? 'Retrieve a single value from the server based on the input time and retrieval type.' >??? 8040???????????????? ret = self._oleobj_.InvokeTypes(9, LCID, 1, (9, 0), ((12, 1), (3, 1), (9, 49)),TimeStamp > -> 8041???????????????????????? , Mode, asynchStatus) >??? 8042???????????????? if ret is not None: >??? 8043???????????????????????? ret = Dispatch(ret, u'ArcValue', '{F293A839-D998-11D3-853F-00C04F45D1DA}') > TypeError: The Python instance can not be converted to a COM object > > c:\programdata\python27\lib\site-packages\win32com\gen_py\0ee075ce-8c31-11d1-bd73-0060b0290178x0x1x1.py(8041)> ArcValue( > ) >??? 8040???????????????? ret = self._oleobj_.InvokeTypes(9, LCID, 1, (9, 0), ((12, 1), (3, 1), (9, 49)),TimeStamp > -> 8041???????????????????????? , Mode, asynchStatus) >??? 8042???????????????? if ret is not None: ? As this code-snippet shows, calling a property on the object works fine, but calling *any* method consistently throws the "The Python instance can not be converted to a COM object" error. I don't have much (any) experience using COM / OLE / ODBC in Python and any help would be appreciated. ? Environment: Python 2.7.3 (32-bit, EPD) with pywin32 build 218 (32-bit) . Windows 7, 64-bit ? Thanks, -fj?.ArcValue("10-JAN-2013 1:00:00.")=pi_server.PIPoints.Item('mytag'); -------------- next part -------------- An HTML attachment was scrubbed... URL: From trevor.rowland at goldtoothcreative.com Mon Jan 14 18:49:34 2013 From: trevor.rowland at goldtoothcreative.com (Trevor Rowland) Date: Mon, 14 Jan 2013 09:49:34 -0800 Subject: [python-win32] Active Directory group creation Message-ID: Hi, Has anyone managed to create an Active Directory group using either win32com.client or active_directroy modules ? if so how? I have a script automatically adding users to active directory groups when they are added to projects in our project management system, but ideally I would like to automatically create groups when they are created in the same system Thanks for any pointers ! -- *Employee Full Name**, Job Title* Goldtooth Creative Agency, Inc. 1.604.568.9168 goldtoothcreative.com * * *The information contained in this email message and any attachments is intended only for the use of the designated recipient(s) named above, is confidential to the designated recipient(s) and may contain information that is privileged and/or is otherwise protected from disclosure under applicable law. If the recipient of this email is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this email in error, and that any review, dissemination, distribution or copying of the information contained herein or attached hereto is strictly prohibited. If you have received this email message in error, please notify me immediately by return email, and delete the original email message and all copies from your records.* -------------- next part -------------- An HTML attachment was scrubbed... URL: From tomthemighty at googlemail.com Mon Jan 14 23:32:04 2013 From: tomthemighty at googlemail.com (Tom Bowles) Date: Mon, 14 Jan 2013 22:32:04 +0000 Subject: [python-win32] Python Finalisation In-Reply-To: References: <20130110171500.GB3126@panix.com> Message-ID: On 10 January 2013 18:48, Tom Bowles wrote: > > On 10 January 2013 17:15, Aahz wrote: >> >> On Thu, Jan 10, 2013, Tom Bowles wrote: >> > >> > Hi, I have a question regarding python finalisation when using pywin32. >> > The details are at >> > http://stackoverflow.com/questions/14257654/how-should-i-or-should-i-finalize-python-in-the-presence-of-pywin32. >> > I can reproduce the question here if preferred, but there's a lot of >> > formatting and I'm posting this from a phone. Hope the stackoverflow link >> > is acceptable. >> >> I'm certainly not looking at Stackoverflow, and it disrupts the archives >> of this list. Please repeat your full question here. >> -- >> Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ >> >> Weinberg's Second Law: If builders built buildings the way programmers wrote >> programs, then the first woodpecker that came along would destroy civilization. > > > > Sure. For a more specialist audience than SO it boils down to: > > 1. Should I call PyWinGlobals_Free() before calling Py_Finalize()? If I don't I get errors, which I can give more detail about if you want. > > > 2. Why does pycom's dllmain.cpp contain a comment implying that it is not safe to "ever" finalize python "in the COM world". > 3. What happened to the pycom-dev archive? pythonpros.com, which all the links to it I can find point to, appears to be a sedo parking thing. > > > Tom Does anybody have any thoughts on this? If I call Py_Finalize() without calling PyWinGlobals_Free(), then after I re-initialize python and start using pywin32 again I get "NoneType is not callable" errors, which appear to originate on line 3 of the string that is executed with PyRun_String() in pywintypesmodule.cpp. This string contains the definition of a class called "error". It appears that the class definition is somehow surviving across the python reinitialisation, but in a broken state, so that when it eventually gets used again the value of "len" is None, instead of the len() function as it should be. Calling PyWinGlobals_Free() before finalising python causes the state to be reset so that on reinitialisation the "error" class definition string gets executed again with PyRun_String(). This avoids the errors I have experienced, but I don't know if it's the right thing to do. On the one hand, at the C++ code level it looks plausible that the PyWinGlobals_Free() export is intended to be called as a cleanup before finalisation. Also, in the dllmain.cpp file for pycom, there is commented out finalisation code which calls PyWinGlobals_Free(), which suggests it might be the right thing to do. On the other hand, there is no mention at all of PyWinGlobals_Free() in the pywin32 documentation, and there is no indication there (or anywhere else I can find) that it is necessary to do anything special before finalising python when using pywin32. Also, the dllmain.cpp file in pycom has a comment suggesting that finalisation might not be safe at all, and the file mentions the "pycom-dev" archives as a source of further information. However, these archives no longer appear to exist. It looks like the domain registration for pythonpros.com has expired. Any clarification you can provide would be very helpful. Thanks, Tom From mail at timgolden.me.uk Tue Jan 15 10:09:16 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 Jan 2013 09:09:16 +0000 Subject: [python-win32] Active Directory group creation In-Reply-To: References: Message-ID: <50F51CBC.3000602@timgolden.me.uk> On 14/01/2013 17:49, Trevor Rowland wrote: > Has anyone managed to create an Active Directory group using either > win32com.client or active_directroy modules ? if so how? > > I have a script automatically adding users to active directory groups > when they are added to projects in our project management system, but > ideally I would like to automatically create groups when they are > created in the same system It's not too hard to do it with native win32com: import win32com.client # # Adjust to suit, obviously... # dn = "OU=Test,OU=Camden,DC=XX,DC=XX,DC=XX" ou = win32com.client.GetObject("LDAP://%s" % dn) group = ou.Create("group", "cn=testgroup") group.displayName = "Test Group" group.SetInfo() If you're already using the active_directory module anyway, the current git version [*] (note to self: make a new release) offers a bit of syntax sugar here: import active_directory dn = "OU=Test,OU=Camden,DC=XX,DC=XX,DC=XX" ou = active_directory.AD_object("LDAP://%s" % dn) ou['cn=testgroup2'] = dict(Class="group", displayName="Test Group2") group = ou['testgroup2'] # # or # group = ou.add( "cn=testgroup3", Class="group", displayName="Test Group3" ) The __setitem__ approach is a little clunky; it's there more to be parallel with its slightly easier __getitem__ and __delitem__ siblings. TJG [*] https://github.com/tjguk/active_directory From niki at vintech.bg Tue Jan 15 10:32:00 2013 From: niki at vintech.bg (niki) Date: Tue, 15 Jan 2013 11:32:00 +0200 Subject: [python-win32] Python Finalisation In-Reply-To: References: <20130110171500.GB3126@panix.com> Message-ID: <50F52210.9030000@vintech.bg> On 15.01.2013 00:32, Tom Bowles wrote:> > > Does anybody have any thoughts on this? IIRC re-initialization of binary modules is supported in python3. Hope to be wrong, Niki From lonemover at gmail.com Tue Jan 15 07:32:21 2013 From: lonemover at gmail.com (lonemover) Date: Tue, 15 Jan 2013 14:32:21 +0800 Subject: [python-win32] problem with win32print Message-ID: <50f4f7f4.cade440a.72b0.6ce2@mx.google.com> Hi guys, I got a problem with win32print. I learned win32print's usage from http://timgolden.me.uk/pywin32-docs/win32print.html. I have a printer with paper cutting blade. When I using "print the test page" function, in the end the printer will automatically cuts the page. How can I do the cutting thing with win32print api? I don't find any related functions here. Maybe I just need to send some special chars to the printer with WritePrinter function? Hope for your tips. Thx a lot. 2013-01-15 Ivan Jobs -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jan 15 19:05:15 2013 From: timr at probo.com (Tim Roberts) Date: Tue, 15 Jan 2013 10:05:15 -0800 Subject: [python-win32] problem with win32print In-Reply-To: <50f4f7f4.cade440a.72b0.6ce2@mx.google.com> References: <50f4f7f4.cade440a.72b0.6ce2@mx.google.com> Message-ID: <50F59A5B.40004@probo.com> lonemover wrote: > Hi guys, > I got a problem with win32print. I learned win32print's usage from > http://timgolden.me.uk/pywin32-docs/win32print.html. > > I have a printer with paper cutting blade. When I using "print the > test page" function, in the end the printer will automatically cuts > the page. How can I do the cutting thing with win32print api? I don't > find any related functions here. Maybe I just need to send some > special chars to the printer with WritePrinter function? Not surprisingly, there are no blade functions in the Windows API. The test page operation is very simple, and it also knows nothing about blades, so it can't be anything complicated. Are you being very careful to call StartDoc / EndDoc and StartPage / EndPage in matched pairs? I would assume that it's the "EndPage" operation that triggers the blade. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Mon Jan 21 05:34:38 2013 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 21 Jan 2013 15:34:38 +1100 Subject: [python-win32] Python Finalisation In-Reply-To: References: <20130110171500.GB3126@panix.com> Message-ID: <50FCC55E.4000403@gmail.com> Unfortunately there are a number of problems repeatedly initializing and finalizing Python, hence the code you saw in pywin32 that no longer attempts to support it. The short-story is simply that doing this is not supported using pywin32 (at least until the issues in Python are fixed via the new module API which supports this, and pywin32 is adjusted accordingly) Mark On 15/01/2013 9:32 AM, Tom Bowles wrote: > On 10 January 2013 18:48, Tom Bowles wrote: >> >> On 10 January 2013 17:15, Aahz wrote: >>> >>> On Thu, Jan 10, 2013, Tom Bowles wrote: >>>> >>>> Hi, I have a question regarding python finalisation when using pywin32. >>>> The details are at >>>> http://stackoverflow.com/questions/14257654/how-should-i-or-should-i-finalize-python-in-the-presence-of-pywin32. >>>> I can reproduce the question here if preferred, but there's a lot of >>>> formatting and I'm posting this from a phone. Hope the stackoverflow link >>>> is acceptable. >>> >>> I'm certainly not looking at Stackoverflow, and it disrupts the archives >>> of this list. Please repeat your full question here. >>> -- >>> Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ >>> >>> Weinberg's Second Law: If builders built buildings the way programmers wrote >>> programs, then the first woodpecker that came along would destroy civilization. >> >> >> >> Sure. For a more specialist audience than SO it boils down to: >> >> 1. Should I call PyWinGlobals_Free() before calling Py_Finalize()? If I don't I get errors, which I can give more detail about if you want. >> >> >> 2. Why does pycom's dllmain.cpp contain a comment implying that it is not safe to "ever" finalize python "in the COM world". >> 3. What happened to the pycom-dev archive? pythonpros.com, which all the links to it I can find point to, appears to be a sedo parking thing. >> >> >> Tom > > > Does anybody have any thoughts on this? > > If I call Py_Finalize() without calling PyWinGlobals_Free(), then > after I re-initialize python and start using pywin32 again I get > "NoneType is not callable" errors, which appear to originate on line 3 > of the string that is executed with PyRun_String() in > pywintypesmodule.cpp. This string contains the definition of a class > called "error". > > It appears that the class definition is somehow surviving across the > python reinitialisation, but in a broken state, so that when it > eventually gets used again the value of "len" is None, instead of the > len() function as it should be. > > Calling PyWinGlobals_Free() before finalising python causes the state > to be reset so that on reinitialisation the "error" class definition > string gets executed again with PyRun_String(). This avoids the errors > I have experienced, but I don't know if it's the right thing to do. > > On the one hand, at the C++ code level it looks plausible that the > PyWinGlobals_Free() export is intended to be called as a cleanup > before finalisation. Also, in the dllmain.cpp file for pycom, there is > commented out finalisation code which calls PyWinGlobals_Free(), which > suggests it might be the right thing to do. > > On the other hand, there is no mention at all of PyWinGlobals_Free() > in the pywin32 documentation, and there is no indication there (or > anywhere else I can find) that it is necessary to do anything special > before finalising python when using pywin32. Also, the dllmain.cpp > file in pycom has a comment suggesting that finalisation might not be > safe at all, and the file mentions the "pycom-dev" archives as a > source of further information. However, these archives no longer > appear to exist. It looks like the domain registration for > pythonpros.com has expired. > > Any clarification you can provide would be very helpful. > > Thanks, > Tom > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From jean.marc.dev at gmail.com Wed Jan 23 16:45:06 2013 From: jean.marc.dev at gmail.com (Jean Rousseau) Date: Wed, 23 Jan 2013 10:45:06 -0500 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) Message-ID: Hi All, I would appreciate some help with troubleshooting an error I now receive with a pythonservice.exe / pywin32-related services. Here's the background - platform is Win 2003 Server x86: 1. My test machine was running Python 3.2.3 / pywin32 build 217 and all was well with the service classes that I wrote and tested. 2. I then installed Python 3.3.0 and pywin32 build 218. 3. I uninstalled pywin32-b217 and Python 3.2.3 and deleted the subdirs. 4. Rebooted the server. 5. I copied my service code to the server and installed my service class (ie. install), which completed fine. However, the service fails immediately upon startup with the following failure: *The instance's SvcRun() method failed * *Traceback (most recent call last):* * File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", line 834, in SvcRun* * self.ReportServiceStatus(win32service.SERVICE_RUNNING)* * File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", line 797, in ReportServiceStatus* * win32service.SetServiceStatus( self.ssh, status)* *tuple: (13, 'SetServiceStatus', 'The data is invalid.') * *%2: %3* Puzzled by this, I though that pythonservice.exe may have some registration issue, so I tried to /register it, but received the following message: *Registering the Python Service Manager...* *Registration failed as sys.winver is not available or not a string* * * So, I'm pretty confused. The service code has worked flawlessly up until now, and now I get this strange error after moving to Python 3.3. I have taken some obvious actions - I uninstalled Python and pywin32 and deleted the associated subdirs (twice!), restarted the server and reinstalled, but no success. What am I missing?? I have Mark's book, but the section on services doesn't shed any light on this error (nor do I expect it to). I am thankful for any help. TIA, Jean-Marc -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Jan 23 17:50:31 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Jan 2013 16:50:31 +0000 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) In-Reply-To: References: Message-ID: <510014D7.6040508@timgolden.me.uk> On 23/01/2013 15:45, Jean Rousseau wrote: > Here's the background - platform is Win 2003 Server x86: > 1. My test machine was running Python 3.2.3 / pywin32 build 217 and all > was well with the service classes that I wrote and tested. > 2. I then installed Python 3.3.0 and pywin32 build 218. > 3. I uninstalled pywin32-b217 and Python 3.2.3 and deleted the subdirs. > 4. Rebooted the server. > 5. I copied my service code to the server and installed my service class > (ie. install), which completed fine. > > However, the service fails immediately upon startup with the following > failure: > /The instance's SvcRun() method failed / > /Traceback (most recent call last):/ > / File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", > line 834, in SvcRun/ > / self.ReportServiceStatus(win32service.SERVICE_RUNNING)/ > / File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", > line 797, in ReportServiceStatus/ > / win32service.SetServiceStatus( self.ssh, status)/ > /tuple: (13, 'SetServiceStatus', 'The data is invalid.') / > /%2: %3/ I can run a trivial service successfully with Python 3.3 / pywin32 218 on Windows 7. So the combination isn't fatal; might be Win2k3, I suppose. TJG From jean.marc.dev at gmail.com Wed Jan 23 19:30:38 2013 From: jean.marc.dev at gmail.com (Jean Rousseau) Date: Wed, 23 Jan 2013 13:30:38 -0500 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) In-Reply-To: <510014D7.6040508@timgolden.me.uk> References: <510014D7.6040508@timgolden.me.uk> Message-ID: Tim, Thanks for the feedback. Thinking back, I believe that I ran the service without issue after installing 3.3.0 and pywin32-218, and once satisfied that everything was working on the new release, went and uninstalled Python 3.2.3 and pywin-217. I think it was THEN that the service wouldn't function, so I'm (almost) certain that Win 2003 isn't the issue. JM On Wed, Jan 23, 2013 at 11:50 AM, Tim Golden wrote: > On 23/01/2013 15:45, Jean Rousseau wrote: > > Here's the background - platform is Win 2003 Server x86: > > 1. My test machine was running Python 3.2.3 / pywin32 build 217 and all > > was well with the service classes that I wrote and tested. > > 2. I then installed Python 3.3.0 and pywin32 build 218. > > 3. I uninstalled pywin32-b217 and Python 3.2.3 and deleted the subdirs. > > 4. Rebooted the server. > > 5. I copied my service code to the server and installed my service class > > (ie. install), which completed fine. > > > > However, the service fails immediately upon startup with the following > > failure: > > /The instance's SvcRun() method failed / > > /Traceback (most recent call last):/ > > / File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", > > line 834, in SvcRun/ > > / self.ReportServiceStatus(win32service.SERVICE_RUNNING)/ > > / File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", > > line 797, in ReportServiceStatus/ > > / win32service.SetServiceStatus( self.ssh, status)/ > > /tuple: (13, 'SetServiceStatus', 'The data is invalid.') / > > /%2: %3/ > > I can run a trivial service successfully with Python 3.3 / pywin32 218 > on Windows 7. So the combination isn't fatal; might be Win2k3, I suppose. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jean.marc.dev at gmail.com Wed Jan 23 20:55:25 2013 From: jean.marc.dev at gmail.com (Jean Rousseau) Date: Wed, 23 Jan 2013 14:55:25 -0500 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) In-Reply-To: References: <510014D7.6040508@timgolden.me.uk> Message-ID: Tim, OK, so I restored the server VM from backup, ran the existing service (which worked fine) and then copied across and installed my new service .py files and installed. ALL of this still working on Python 3.2.3 and pywin-217. I ran pythonservice with the debug switch on, and now I think we're much closer to the root cause (the Python 3.3.0 upgrade etc was a red herring). Here's the error I now get: E r r o r 0 x C 0 0 0 0 0 F 4 - C o u l d n o t f i n d t h e s e r v i c e ' s P y t h o n C l a s s e n t r y i n t h e r e g i s t r y E r r o r 1 8 1 4 - T h e s p e c i f i e d r e s o u r c e n a m e c a n n o t b e f o u n d i n t h e i m a g e f i l e . E r r o r 0 x C 0 0 0 0 0 8 0 - C o u l d n o t l o c a t e t h e m o d u l e n a m e i n t h e P y t h o n c l a s s s t r i n g ( i e , n o ' . ' ) Well, I checked the registry and the entry for the service is there, along with all the meta-data that it apparently requires (ie. PythonClass IS there with it's full path and (.) dot etc). This makes no sense to me... Any thoughts? JM On Wed, Jan 23, 2013 at 1:30 PM, Jean Rousseau wrote: > Tim, > > Thanks for the feedback. Thinking back, I believe that I ran the service > without issue after installing 3.3.0 and pywin32-218, and once satisfied > that everything was working on the new release, went and uninstalled Python > 3.2.3 and pywin-217. I think it was THEN that the service wouldn't > function, so I'm (almost) certain that Win 2003 isn't the issue. > > JM > > > On Wed, Jan 23, 2013 at 11:50 AM, Tim Golden wrote: > >> On 23/01/2013 15:45, Jean Rousseau wrote: >> > Here's the background - platform is Win 2003 Server x86: >> > 1. My test machine was running Python 3.2.3 / pywin32 build 217 and all >> > was well with the service classes that I wrote and tested. >> > 2. I then installed Python 3.3.0 and pywin32 build 218. >> > 3. I uninstalled pywin32-b217 and Python 3.2.3 and deleted the subdirs. >> > 4. Rebooted the server. >> > 5. I copied my service code to the server and installed my service class >> > (ie. install), which completed fine. >> > >> > However, the service fails immediately upon startup with the following >> > failure: >> > /The instance's SvcRun() method failed / >> > /Traceback (most recent call last):/ >> > / File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", >> > line 834, in SvcRun/ >> > / self.ReportServiceStatus(win32service.SERVICE_RUNNING)/ >> > / File "C:\Python33\lib\site-packages\win32\lib\win32serviceutil.py", >> > line 797, in ReportServiceStatus/ >> > / win32service.SetServiceStatus( self.ssh, status)/ >> > /tuple: (13, 'SetServiceStatus', 'The data is invalid.') / >> > /%2: %3/ >> >> I can run a trivial service successfully with Python 3.3 / pywin32 218 >> on Windows 7. So the combination isn't fatal; might be Win2k3, I suppose. >> >> TJG >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Jan 23 21:03:23 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Jan 2013 20:03:23 +0000 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) In-Reply-To: References: <510014D7.6040508@timgolden.me.uk> Message-ID: <5100420B.9060203@timgolden.me.uk> On 23/01/2013 19:55, Jean Rousseau wrote: > Tim, > > OK, so I restored the server VM from backup, ran the existing service > (which worked fine) and then copied across and installed my new service .py > files and installed. ALL of this still working on Python 3.2.3 and > pywin-217. I ran pythonservice with the debug switch on, and now I think > we're much closer to the root cause (the Python 3.3.0 upgrade etc was a red > herring). > > Here's the error I now get: > E r r o r 0 x C 0 0 0 0 0 F 4 - C o u l d n o t f i n d t h e > s e > r v i c e ' s P y t h o n C l a s s e n t r y i n t h e r e g i s > t r > y > E r r o r 1 8 1 4 - T h e s p e c i f i e d r e s o u r c e n a > m e > c a n n o t b e f o u n d i n t h e i m a g e f i l e . > E r r o r 0 x C 0 0 0 0 0 8 0 - C o u l d n o t l o c a t e t h > e > m o d u l e n a m e i n t h e P y t h o n c l a s s s t r i n g > ( > i e , n o ' . ' ) > > Well, I checked the registry and the entry for the service is there, along > with all the meta-data that it apparently requires (ie. PythonClass IS > there with it's full path and (.) dot etc). This makes no sense to me... Nor me, either, I'm afraid. Hopefully someone else can chip in. I realise that the service was running successfully under the old configuration, but is there any mileage in your showing us the Python code around the service, in case something jumps out? TJG From jean.marc.dev at gmail.com Wed Jan 23 22:23:33 2013 From: jean.marc.dev at gmail.com (Jean Rousseau) Date: Wed, 23 Jan 2013 16:23:33 -0500 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) In-Reply-To: <5100420B.9060203@timgolden.me.uk> References: <510014D7.6040508@timgolden.me.uk> <5100420B.9060203@timgolden.me.uk> Message-ID: Tim, Thanks for the help - I have appreciated the input! After (much) further troubleshooting, I have located the bug - completely my fault (why aren't you more surprised? ;-) The service fails on startup because my own derived class implemented a method that is only supported on platforms later than Win 2003. This caused GetAcceptedControls to return an invalid request ID, which in turn caused SetServiceStatus to fail. Turns out that I had deleted this method in the working version of the service. Thanks again for your feedback. JM On Wed, Jan 23, 2013 at 3:03 PM, Tim Golden wrote: > On 23/01/2013 19:55, Jean Rousseau wrote: > >> Tim, >> >> OK, so I restored the server VM from backup, ran the existing service >> (which worked fine) and then copied across and installed my new service >> .py >> files and installed. ALL of this still working on Python 3.2.3 and >> pywin-217. I ran pythonservice with the debug switch on, and now I think >> we're much closer to the root cause (the Python 3.3.0 upgrade etc was a >> red >> herring). >> >> Here's the error I now get: >> E r r o r 0 x C 0 0 0 0 0 F 4 - C o u l d n o t f i n d t h e >> s e >> r v i c e ' s P y t h o n C l a s s e n t r y i n t h e r e g i >> s >> t r >> y >> E r r o r 1 8 1 4 - T h e s p e c i f i e d r e s o u r c e n >> a >> m e >> c a n n o t b e f o u n d i n t h e i m a g e f i l e . >> E r r o r 0 x C 0 0 0 0 0 8 0 - C o u l d n o t l o c a t e t >> h >> e >> m o d u l e n a m e i n t h e P y t h o n c l a s s s t r i n >> g >> ( >> i e , n o ' . ' ) >> >> Well, I checked the registry and the entry for the service is there, along >> with all the meta-data that it apparently requires (ie. PythonClass IS >> there with it's full path and (.) dot etc). This makes no sense to me... >> > > Nor me, either, I'm afraid. Hopefully someone else can chip in. > > I realise that the service was running successfully under the old > configuration, but is there any mileage in your showing us the Python code > around the service, in case something jumps out? > > > TJG > > ______________________________**_________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/**mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Jan 24 09:32:46 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Jan 2013 08:32:46 +0000 Subject: [python-win32] pywin32 service startup error (sys.winver issue?) In-Reply-To: References: <510014D7.6040508@timgolden.me.uk> <5100420B.9060203@timgolden.me.uk> Message-ID: <5100F1AE.1020700@timgolden.me.uk> On 23/01/2013 21:23, Jean Rousseau wrote: > After (much) further troubleshooting, I have located the bug - > completely my fault (why aren't you more surprised? ;-) The service > fails on startup because my own derived class implemented a method that > is only supported on platforms later than Win 2003. This caused > GetAcceptedControls to return an invalid request ID, which in turn > caused SetServiceStatus to fail. Turns out that I had deleted this > method in the working version of the service. Thanks for letting us know, Jean. I'm glad it wasn't something more obscure: with all the changes going into Python 3.3, it was quite possible that an odd corner of behaviour would throw up a new problem. TJG From marcelo.cra at hotmail.com Thu Jan 24 19:44:07 2013 From: marcelo.cra at hotmail.com (Marcelo Almeida) Date: Thu, 24 Jan 2013 16:44:07 -0200 Subject: [python-win32] win32print not printing Message-ID: Hello everyone, I am trying to print a string (not a file) with win32print api and I'm using Tim Golden's third block of code (pasted below) as a testing example but without success. There is just no errors and the printer spool show the file rapidly and then nothing occurs. I could print using the ShellExecute but that's not what I need, since it prints files (and file names to pages, which I also don't want). Here is Tim Golden's snippet I'm using to test: import os, sys import win32print printer_name = win32print.GetDefaultPrinter () # # raw_data could equally be raw PCL/PS read from # some print-to-file operation # if sys.version_info >= (3,): raw_data = bytes ("This is a test", "utf-8") else: raw_data = "This is a test" hPrinter = win32print.OpenPrinter (printer_name) try: hJob = win32print.StartDocPrinter (hPrinter, 1, ("test of raw data", None, "RAW")) try: win32print.StartPagePrinter (hPrinter) win32print.WritePrinter (hPrinter, raw_data) win32print.EndPagePrinter (hPrinter) finally: win32print.EndDocPrinter (hPrinter) finally: win32print.ClosePrinter (hPrinter) Thanks! Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Jan 25 10:15:53 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Jan 2013 09:15:53 +0000 Subject: [python-win32] win32print not printing In-Reply-To: References: Message-ID: <51024D49.3010502@timgolden.me.uk> On 24/01/2013 18:44, Marcelo Almeida wrote: > Hello everyone, > > I am trying to print a string (not a file) with win32print api and I'm > using Tim Golden's > third block of > code (pasted below) as a testing example but without success. There is > just no errors and the printer spool show the file rapidly and then > nothing occurs. I just printed using that code in both Python 2 & Python 3, so there's nothing obvious, I'm afraid. Is it possible that your default printer isn't what you think it is? TJG From marcelo.cra at hotmail.com Fri Jan 25 16:36:36 2013 From: marcelo.cra at hotmail.com (Marcelo Almeida) Date: Fri, 25 Jan 2013 13:36:36 -0200 Subject: [python-win32] win32print not printing Message-ID: > > > On 24/01/2013 18:44, Marcelo Almeida wrote: > > Hello everyone, > > > > I am trying to print a string (not a file) with win32print api and I'm > > using Tim Golden's > > third block of > > code (pasted below) as a testing example but without success. There is > > just no errors and the printer spool show the file rapidly and then > > nothing occurs. > I just printed using that code in both Python 2 & Python 3, so there's > nothing obvious, I'm afraid. Is it possible that your default printer > isn't what you think it is? > TJG No, it's not. I tested it (even using the EnumPrinter name of my printer - which prints with the ShellExecute command) and when I run the script my default printer spool show the document briefly, as if were printing. I'm a little bit confused about one part of the documentation that I found on your website (the last phrase, last line): "Note that the printer driver might ignore the requested data type." I'm guessing that the printer is ignoring the RAW type I'm using. I've tried EMF, EMFSPOOL, TXT but with them I get runtime errors. I also tried to print to a pdf printer (CutePDF Writer) and got a similar problem: the pdf document were created but no contents either. Is there much difference in the underlying code from this method to the ShellExecute method? Why would one work and the other not? Thanks, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jan 25 19:53:27 2013 From: timr at probo.com (Tim Roberts) Date: Fri, 25 Jan 2013 10:53:27 -0800 Subject: [python-win32] win32print not printing In-Reply-To: References: Message-ID: <5102D4A7.9050002@probo.com> Marcelo Almeida wrote: > > I am trying to print a string (not a file) with win32print api and I'm > using Tim Golden's > third block > of code (pasted below) as a testing example but without success. There > is just no errors and the printer spool show the file rapidly and then > nothing occurs. I could print using the ShellExecute but that's not > what I need, since it prints files (and file names to pages, which I > also don't want). Here is Tim Golden's snippet I'm using to test: What printer is this? Most printers these days expect to receive their "printer control language" (PCL or Postscript or whatever). They don't have any idea what to do with a raw text string. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From marcelo.cra at hotmail.com Fri Jan 25 21:50:48 2013 From: marcelo.cra at hotmail.com (Marcelo Almeida) Date: Fri, 25 Jan 2013 18:50:48 -0200 Subject: [python-win32] win32print not printing Message-ID: > > Marcelo Almeida wrote: > > > >* I am trying to print a string (not a file) with win32print api and I'm > *>* using Tim Golden's > *>* third block > *>* of code (pasted below) as a testing example but without success. There > *>* is just no errors and the printer spool show the file rapidly and then > * > >* nothing occurs. I could print using the ShellExecute but that's not > *>* what I need, since it prints files (and file names to pages, which I > *>* also don't want). Here is Tim Golden's snippet I'm using to test: > * > What printer is this? Most printers these days expect to receive their > "printer control language" (PCL or Postscript or whatever). They don't > have any idea what to do with a raw text string. > -- > Tim Roberts, timr at probo.com > Providenza & > Boekelheide, Inc. HP Deskjet F4480. I'll look into this PCL. Maybe that's the way. Thanks to both of you! -------------- next part -------------- An HTML attachment was scrubbed... URL: From victor_hsu at Compalcomm.com Sun Jan 27 13:37:31 2013 From: victor_hsu at Compalcomm.com (Hsu. Victor (GSM)) Date: Sun, 27 Jan 2013 12:37:31 +0000 Subject: [python-win32] Help for Excel Pivot Copy Message-ID: <360FC6984C33144EBC925A08B7CD49FE03F8F9@CCITPEMS6.tpe.compalcomm.com> Hi, I would like to copy a Pivot table to another location. I can do that with VBA code below. Can someone guide me how to convert below code to Python? Especailly the PivotTables PivotSelect part, I don't know how to call it in python. Sub copyPivot() Dim ws As Worksheet Set ws = Worksheets.Add Sheets("PV1").Select ActiveSheet.PivotTables("Pivot1").PivotSelect "", xlDataAndLabel, True Selection.Copy ws.Range("A1").PasteSpecial End Sub Victor This message may contain information which is private, privileged or confidential of Compal Communications, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. CCI 2013 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rsavutiu at gmail.com Mon Jan 28 16:34:29 2013 From: rsavutiu at gmail.com (Radu Savutiu) Date: Mon, 28 Jan 2013 17:34:29 +0200 Subject: [python-win32] win32gui.EnumWindows does not work on worker threads Message-ID: Hi all, I have multiple scripts in which i used win32gui.EnumWindows. So far they all worked - but now it seems they pause on this call to EnumWindows. I suspect this has nothing to do with pythoncom, as I use CoInitialize there and it works. Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Mon Jan 28 16:57:30 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 28 Jan 2013 15:57:30 +0000 Subject: [python-win32] win32gui.EnumWindows does not work on worker threads In-Reply-To: References: Message-ID: <51069FEA.6010507@timgolden.me.uk> On 28/01/2013 15:34, Radu Savutiu wrote: > I have multiple scripts in which i used win32gui.EnumWindows. > So far they all worked - but now it seems they pause on this call to > EnumWindows. > > I suspect this has nothing to do with pythoncom, as I use CoInitialize > there and it works. It's not entirely clear from your description what you're doing and what's going wrong. By way of experiment this works for me: (Win7, Python 2.7) import Queue import threading import win32gui q = Queue.Queue() t = threading.Thread( target=win32gui.EnumWindows, args=(q.put, None) ) t.start() while True: print q.get_nowait() TJG From timr at probo.com Tue Jan 29 01:55:44 2013 From: timr at probo.com (Tim Roberts) Date: Mon, 28 Jan 2013 16:55:44 -0800 Subject: [python-win32] win32gui.EnumWindows does not work on worker threads In-Reply-To: References: Message-ID: <51071E10.5000200@probo.com> Radu Savutiu wrote: > > I have multiple scripts in which i used win32gui.EnumWindows. > So far they all worked - but now it seems they pause on this call to > EnumWindows. > > I suspect this has nothing to do with pythoncom, as I use CoInitialize > there and it works. No, it has nothing to do with COM. EnumWindows is a GDI call. EnumWindows does nothing but stroll through a data structure. It cannot pause. It's more likely that your callback is doing something time consuming. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From victor_hsu at Compalcomm.com Tue Jan 29 05:22:45 2013 From: victor_hsu at Compalcomm.com (Hsu. Victor (GSM)) Date: Tue, 29 Jan 2013 04:22:45 +0000 Subject: [python-win32] OpenDataSource failed in ms-word-mail-merge-automation Message-ID: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> Hi, I am trying to use this python sample code to create automatic daily report. http://bytes.com/topic/python/answers/165364-ms-word-mail-merge-automation but I always failed to open the data source in CSV file. Is this python issue or Windows COM version issue? Anyone knows this? F:\pythonprogram>python WordEmail.py Traceback (most recent call last): File "WordEmail.py", line 17, in mm.OpenDataSource(data_source_name) File "C:\Users\VICTOR~1\AppData\Local\Temp\gen_py\2.7\00020905-0000-0000-C000- 000000000046x0x8x5\MailMerge.py", line 65, in OpenDataSource , Connection, SQLStatement, SQLStatement1, OpenExclusive, SubType pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word' , u'\u627e\u4e0d\u5230\u6a94\u6848\u3002\r (F:\\Google \u96f2\u7aef\u786c\u789f\ \...\\\receipent.csv)', u'wdmain11.chm', 24654, -2146823114), None) Victor This message may contain information which is private, privileged or confidential of Compal Communications, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. CCI 2013 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jan 29 09:56:46 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 Jan 2013 08:56:46 +0000 Subject: [python-win32] Help for Excel Pivot Copy In-Reply-To: <360FC6984C33144EBC925A08B7CD49FE03F8F9@CCITPEMS6.tpe.compalcomm.com> References: <360FC6984C33144EBC925A08B7CD49FE03F8F9@CCITPEMS6.tpe.compalcomm.com> Message-ID: <51078ECE.30401@timgolden.me.uk> On 27/01/2013 12:37, Hsu. Victor (GSM) wrote: > Hi, > > I would like to copy a Pivot table to another location. > I can do that with VBA code below. Can someone guide me how to convert > below code to Python? Especailly the PivotTables PivotSelect part, I > don't know how to call it in python. > > Sub copyPivot() > Dim ws As Worksheet > Set ws = Worksheets.Add > Sheets("PV1").Select > ActiveSheet.PivotTables("Pivot1").PivotSelect "", xlDataAndLabel, True > Selection.Copy > ws.Range("A1").PasteSpecial > End Sub I don't have a sheet with a pivot table (and I can't be bothered to generate one :) ) but hopefully the code below will show you enough of the pattern to get you going. It's untested so there may be some slight flaws: import win32com.client const = win32com.client.constants wb = win32com.client.GetObject(r"c:\path\to\spreadshset.xls") ws = wb.Worksheets.Add() wb.Sheets("PV1").Select() wb.ActiveSheet.PivotTables("Pivot1").PivotSelect( "", const.xlDataAndLabel, True) wb.Application.Selection.Copy() ws.Range("A1").PastSpecial() TJG From jmfrank63 at gmail.com Tue Jan 29 15:48:09 2013 From: jmfrank63 at gmail.com (Johannes Frank) Date: Tue, 29 Jan 2013 15:48:09 +0100 Subject: [python-win32] python win32com design question Message-ID: Hello, I am currently working with win32com to access ProgeCAD (an AutoCAD Clone) Excel and PDFCreator. Using comobj = win32com.client.Dispatch('xxx') gives me an object through which I can access the COM interface and thus the underlying program. Within my program I have to pass this object around to make the interface accessible whereever it is needed. Closing the program creates huge problems, as now the object is void. Instead of getting an object I would prefer to have: class MyCom(win32com.some_inheritance): some code mycom = MyCom('xxx') Is something like this possible? If not, is there a reason it was designed the way it is? Thank you for your audience. Kind regards Johannes -- Dipl.-Ing. (FH) Johannes-Maria Frank Bildungsberater K?nigsberger-Str. 19b 76139 Karlsruhe Tel. +49(170) 3833849 e-mail: jmfrank63 at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jan 29 18:59:42 2013 From: timr at probo.com (Tim Roberts) Date: Tue, 29 Jan 2013 09:59:42 -0800 Subject: [python-win32] OpenDataSource failed in ms-word-mail-merge-automation In-Reply-To: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> References: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> Message-ID: <51080E0E.6040402@probo.com> Hsu. Victor (GSM) wrote: > > > I am trying to use this python sample code to create automatic > daily report. > > http://bytes.com/topic/python/answers/165364-ms-word-mail-merge-automation > > > > but I always failed to open the data source in CSV file. Is this > python issue or Windows COM version issue? > > Anyone knows this? > > > > F:\pythonprogram>python WordEmail.py > > Traceback (most recent call last): > > File "WordEmail.py", line 17, in > > mm.OpenDataSource(data_source_name) > > File > "C:\Users\VICTOR~1\AppData\Local\Temp\gen_py\2.7\00020905-0000-0000-C000- > > 000000000046x0x8x5\MailMerge.py", line 65, in OpenDataSource > > , Connection, SQLStatement, SQLStatement1, OpenExclusive, SubType > > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, > u'Microsoft Word' > > , u'\u627e\u4e0d\u5230\u6a94\u6848\u3002\r (F:\\Google > \u96f2\u7aef\u786c\u789f\ > > \...\\\receipent.csv)', u'wdmain11.chm', 24654, -2146823114), None) > -2146823114 in hex is 800A1436, which is "this file could not be found". I see that you have misspelled "recipient". Could that be the root cause? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Tue Jan 29 21:52:18 2013 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 29 Jan 2013 15:52:18 -0500 Subject: [python-win32] python win32com design question In-Reply-To: References: Message-ID: <51083682.1010500@gmail.com> On 29/01/2013 9:48 AM, Johannes Frank wrote: > Hello, > > I am currently working with win32com to access ProgeCAD (an AutoCAD > Clone) Excel and PDFCreator. > Using > > comobj = win32com.client.Dispatch('xxx') > > gives me an object through which I can access the COM interface and > thus the underlying program. > Within my program I have to pass this object around to make the > interface accessible whereever it is needed. Closing the program creates > huge problems, as now the object is void. > > Instead of getting an object I would prefer to have: > > class MyCom(win32com.some_inheritance): > some code It's not clear what you mean by "win32com.some_inheritance" given there are an unbounded number of objects that could apply here. You can obviously encapsulate the COM object inside your class though: class MyCom: def __init__(self, progid): self.com = win32com.client.Dispatch(progid) HTH, Mark > > > mycom = MyCom('xxx') > > Is something like this possible? If not, is there a reason it was > designed the way it is? > > Thank you for your audience. > > Kind regards > > Johannes > > -- > Dipl.-Ing. (FH) Johannes-Maria Frank > Bildungsberater > K?nigsberger-Str. 19b > 76139 Karlsruhe > Tel. +49(170) 3833849 > e-mail: jmfrank63 at gmail.com > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From victor_hsu at Compalcomm.com Wed Jan 30 04:45:17 2013 From: victor_hsu at Compalcomm.com (Hsu. Victor (GSM)) Date: Wed, 30 Jan 2013 03:45:17 +0000 Subject: [python-win32] OpenDataSource failed inms-word-mail-merge-automation In-Reply-To: <51080E0E.6040402@probo.com> References: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> <51080E0E.6040402@probo.com> Message-ID: <360FC6984C33144EBC925A08B7CD49FE040D61@CCITPEMS6.tpe.compalcomm.com> Hi Tim, I fixed it by doing some modification. data_source_name = os.path.abspath('recipient.csv') mm.OpenDataSource(data_source_name) And the "Word Merge To Document" function works now. However, my intention is to send an email. So I change some setting, #send the merge result to Email mm.Destination = win32com.client.constants.wdSendToEmail #send the merge result to document #mm.Destination = win32com.client.constants.wdSendToNewDocument mm.MailSubject = "This is a test mail from Python Win32---"+time.strftime('%Y_%m_%d') but now, it failed to run again. ================== F:\MyProgram\python\Word2Email>python Word2Email.py Traceback (most recent call last): File "Word2Email.py", line 41, in mm.Execute() File "F:\Python27\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-00 0000000046x0x8x5.py", line 14162, in Execute return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((16396, 17),),Pause pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word' , u'\u6c92\u6709\u78ba\u5b9a\u5730\u5740\uff0cWord \u7121\u6cd5\u5408\u4f75\u53e f\u4f9b\u90f5\u5bc4\u6216\u50b3\u771f\u7684\u6587\u4ef6\u3002\u8acb\u9078\u64c7 [\u8a2d\u5b9a] \u6309\u9215\uff0c\u9078\u53d6\u90f5\u5bc4\u5730\u5740\u8cc7\u659 9\u6b04\u4f4d\u3002', u'wdmain11.chm', 25110, -2146822658), None) Best Regards, Victor -----Original Message----- From: python-win32 [mailto:python-win32-bounces+victor_hsu=compalcomm.com at python.org] On Behalf Of Tim Roberts Sent: Wednesday, January 30, 2013 2:00 AM To: Python-Win32 List Subject: Re: [python-win32] OpenDataSource failed inms-word-mail-merge-automation Hsu. Victor (GSM) wrote: > > > I am trying to use this python sample code to create automatic > daily report. > > http://bytes.com/topic/python/answers/165364-ms-word-mail-merge-automa > tion > > > > but I always failed to open the data source in CSV file. Is this > python issue or Windows COM version issue? > > Anyone knows this? > > > > F:\pythonprogram>python WordEmail.py > > Traceback (most recent call last): > > File "WordEmail.py", line 17, in > > mm.OpenDataSource(data_source_name) > > File > "C:\Users\VICTOR~1\AppData\Local\Temp\gen_py\2.7\00020905-0000-0000-C0 > 00- > > 000000000046x0x8x5\MailMerge.py", line 65, in OpenDataSource > > , Connection, SQLStatement, SQLStatement1, OpenExclusive, SubType > > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, > u'Microsoft Word' > > , u'\u627e\u4e0d\u5230\u6a94\u6848\u3002\r (F:\\Google > \u96f2\u7aef\u786c\u789f\ > > \...\\\receipent.csv)', u'wdmain11.chm', 24654, -2146823114), None) > -2146823114 in hex is 800A1436, which is "this file could not be found". I see that you have misspelled "recipient". Could that be the root cause? -- 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 This message may contain information which is private, privileged or confidential of Compal Communications, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. CCI 2013 From victor_hsu at Compalcomm.com Wed Jan 30 07:04:30 2013 From: victor_hsu at Compalcomm.com (Hsu. Victor (GSM)) Date: Wed, 30 Jan 2013 06:04:30 +0000 Subject: [python-win32] OpenDataSource failed inms-word-mail-merge-automation References: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> <51080E0E.6040402@probo.com> Message-ID: <360FC6984C33144EBC925A08B7CD49FE040E1D@CCITPEMS6.tpe.compalcomm.com> Re-install my Office to English version. Finally know what Word told me. Let me try how to fix this. === F:\MyProgram\python\Word2Email>python Word2Email.py Traceback (most recent call last): File "Word2Email.py", line 41, in mm.Execute() File "F:\Python27\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-00 0000000046x0x8x5.py", line 14162, in Execute return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((16396, 17),),Pause pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word' , u'Word cannot merge documents that can be distributed by mail or fax without a valid mail address. Choose the Setup button to select a mail address data field .', u'wdmain11.chm', 25110, -2146822658), None) -----Original Message----- From: Hsu. Victor (GSM) Sent: Wednesday, January 30, 2013 11:45 AM To: 'Tim Roberts'; Python-Win32 List Subject: RE: [python-win32] OpenDataSource failed inms-word-mail-merge-automation Hi Tim, I fixed it by doing some modification. data_source_name = os.path.abspath('recipient.csv') mm.OpenDataSource(data_source_name) And the "Word Merge To Document" function works now. However, my intention is to send an email. So I change some setting, #send the merge result to Email mm.Destination = win32com.client.constants.wdSendToEmail #send the merge result to document #mm.Destination = win32com.client.constants.wdSendToNewDocument mm.MailSubject = "This is a test mail from Python Win32---"+time.strftime('%Y_%m_%d') but now, it failed to run again. ================== F:\MyProgram\python\Word2Email>python Word2Email.py Traceback (most recent call last): File "Word2Email.py", line 41, in mm.Execute() File "F:\Python27\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-00 0000000046x0x8x5.py", line 14162, in Execute return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((16396, 17),),Pause pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word' , u'\u6c92\u6709\u78ba\u5b9a\u5730\u5740\uff0cWord \u7121\u6cd5\u5408\u4f75\u53e f\u4f9b\u90f5\u5bc4\u6216\u50b3\u771f\u7684\u6587\u4ef6\u3002\u8acb\u9078\u64c7 [\u8a2d\u5b9a] \u6309\u9215\uff0c\u9078\u53d6\u90f5\u5bc4\u5730\u5740\u8cc7\u659 9\u6b04\u4f4d\u3002', u'wdmain11.chm', 25110, -2146822658), None) Best Regards, Victor -----Original Message----- From: python-win32 [mailto:python-win32-bounces+victor_hsu=compalcomm.com at python.org] On Behalf Of Tim Roberts Sent: Wednesday, January 30, 2013 2:00 AM To: Python-Win32 List Subject: Re: [python-win32] OpenDataSource failed inms-word-mail-merge-automation Hsu. Victor (GSM) wrote: > > > I am trying to use this python sample code to create automatic > daily report. > > http://bytes.com/topic/python/answers/165364-ms-word-mail-merge-automa > tion > > > > but I always failed to open the data source in CSV file. Is this > python issue or Windows COM version issue? > > Anyone knows this? > > > > F:\pythonprogram>python WordEmail.py > > Traceback (most recent call last): > > File "WordEmail.py", line 17, in > > mm.OpenDataSource(data_source_name) > > File > "C:\Users\VICTOR~1\AppData\Local\Temp\gen_py\2.7\00020905-0000-0000-C0 > 00- > > 000000000046x0x8x5\MailMerge.py", line 65, in OpenDataSource > > , Connection, SQLStatement, SQLStatement1, OpenExclusive, SubType > > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, > u'Microsoft Word' > > , u'\u627e\u4e0d\u5230\u6a94\u6848\u3002\r (F:\\Google > \u96f2\u7aef\u786c\u789f\ > > \...\\\receipent.csv)', u'wdmain11.chm', 24654, -2146823114), None) > -2146823114 in hex is 800A1436, which is "this file could not be found". I see that you have misspelled "recipient". Could that be the root cause? -- 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 This message may contain information which is private, privileged or confidential of Compal Communications, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. CCI 2013 From victor_hsu at Compalcomm.com Wed Jan 30 08:50:20 2013 From: victor_hsu at Compalcomm.com (Hsu. Victor (GSM)) Date: Wed, 30 Jan 2013 07:50:20 +0000 Subject: [python-win32] OpenDataSource failed inms-word-mail-merge-automation References: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> <51080E0E.6040402@probo.com> Message-ID: <360FC6984C33144EBC925A08B7CD49FE0411C1@CCITPEMS6.tpe.compalcomm.com> Great...finally fix the problem. # #send the merge result to Email mm.MainDocumentType = const.wdEMail mm.Destination = const.wdSendToEmail mm.MailAddressFieldName = "EMail" mm.MailFormat = const.wdMailFormatHTML mm.MailSubject = "This is a test mail from Python Win32---"+time.strftime('%Y_%m_%d_%H_%M_%S') mm.MailFormat = const.wdMailFormatHTML The full source is here: http://weiderhsu.blogspot.tw/2013/01/automatic-email-with-word-python.html -----Original Message----- From: Hsu. Victor (GSM) Sent: Wednesday, January 30, 2013 11:45 AM To: 'Tim Roberts'; Python-Win32 List Subject: RE: [python-win32] OpenDataSource failed inms-word-mail-merge-automation Hi Tim, I fixed it by doing some modification. data_source_name = os.path.abspath('recipient.csv') mm.OpenDataSource(data_source_name) And the "Word Merge To Document" function works now. However, my intention is to send an email. So I change some setting, #send the merge result to Email mm.Destination = win32com.client.constants.wdSendToEmail #send the merge result to document #mm.Destination = win32com.client.constants.wdSendToNewDocument mm.MailSubject = "This is a test mail from Python Win32---"+time.strftime('%Y_%m_%d') but now, it failed to run again. ================== F:\MyProgram\python\Word2Email>python Word2Email.py Traceback (most recent call last): File "Word2Email.py", line 41, in mm.Execute() File "F:\Python27\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-00 0000000046x0x8x5.py", line 14162, in Execute return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((16396, 17),),Pause pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word' , u'\u6c92\u6709\u78ba\u5b9a\u5730\u5740\uff0cWord \u7121\u6cd5\u5408\u4f75\u53e f\u4f9b\u90f5\u5bc4\u6216\u50b3\u771f\u7684\u6587\u4ef6\u3002\u8acb\u9078\u64c7 [\u8a2d\u5b9a] \u6309\u9215\uff0c\u9078\u53d6\u90f5\u5bc4\u5730\u5740\u8cc7\u659 9\u6b04\u4f4d\u3002', u'wdmain11.chm', 25110, -2146822658), None) Best Regards, Victor -----Original Message----- From: python-win32 [mailto:python-win32-bounces+victor_hsu=compalcomm.com at python.org] On Behalf Of Tim Roberts Sent: Wednesday, January 30, 2013 2:00 AM To: Python-Win32 List Subject: Re: [python-win32] OpenDataSource failed inms-word-mail-merge-automation Hsu. Victor (GSM) wrote: > > > I am trying to use this python sample code to create automatic > daily report. > > http://bytes.com/topic/python/answers/165364-ms-word-mail-merge-automa > tion > > > > but I always failed to open the data source in CSV file. Is this > python issue or Windows COM version issue? > > Anyone knows this? > > > > F:\pythonprogram>python WordEmail.py > > Traceback (most recent call last): > > File "WordEmail.py", line 17, in > > mm.OpenDataSource(data_source_name) > > File > "C:\Users\VICTOR~1\AppData\Local\Temp\gen_py\2.7\00020905-0000-0000-C0 > 00- > > 000000000046x0x8x5\MailMerge.py", line 65, in OpenDataSource > > , Connection, SQLStatement, SQLStatement1, OpenExclusive, SubType > > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, > u'Microsoft Word' > > , u'\u627e\u4e0d\u5230\u6a94\u6848\u3002\r (F:\\Google > \u96f2\u7aef\u786c\u789f\ > > \...\\\receipent.csv)', u'wdmain11.chm', 24654, -2146823114), None) > -2146823114 in hex is 800A1436, which is "this file could not be found". I see that you have misspelled "recipient". Could that be the root cause? -- 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 This message may contain information which is private, privileged or confidential of Compal Communications, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. CCI 2013 From NSeigal at lcog.org Wed Jan 30 15:29:16 2013 From: NSeigal at lcog.org (SEIGAL Nick) Date: Wed, 30 Jan 2013 06:29:16 -0800 Subject: [python-win32] building pywin32 for python 2.6... Message-ID: <506F591A54F21D4480EE337F77369C050AD5000709@LCEXG03.lc100.net> I am trying to get pywin32 build 218 installed and am having trouble. Here is the error I am getting: C:\Python26>python F:\Downloads\Python\pywin32\pywin32-218\setup.py install Building pywin32 2.6.218.0 running install running build running build_py running build_ext Found version 0x601 in C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\SDKDDKVER.H building 'perfmondata' extension C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mc.exe -h win32\src\perfmon -r build\temp.win32-2.6\Release\win32\src\ perfmon win32\src\perfmon\PyPerfMsgs.mc MC: Compiling win32\src\perfmon\PyPerfMsgs.mc C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /fobuild\temp.win32-2.6\Release\win32\src\perfmon\PyPerfMsgs.re s build\temp.win32-2.6\Release\win32\src\perfmon\PyPerfMsgs.rc Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385 Copyright (C) Microsoft Corporation. All rights reserved. C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DDISTUTILS_BUILD -D_CR T_SECURE_NO_WARNINGS -Icom/win32com/src/include -Iwin32/src -IC:\Python26\include -IC:\Python26\PC "-IC:\Program Files\M icrosoft SDKs\Windows\v7.0A\include" /Tpwin32\src\perfmon\perfmondata.cpp /Fobuild\temp.win32-2.6\Release\win32\src\perf mon\perfmondata.obj /Zi /Fdbuild\temp.win32-2.6\Release\perfmondata_vc.pdb /EHsc /DMFC_OCC_IMPL_H=\"..\src\occimpl.h\" / DUNICODE /D_UNICODE /DWINNT perfmondata.cpp win32\src\perfmon\perfmondata.cpp(11) : fatal error C1083: Cannot open include file: 'perfutil.h': No such file or direc tory error: command '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe"' failed with exit status 2 I had followed a forum suggestion to set a VS90COMNTOOLS environmental variable to my VS2010 VS100COMNTOOLS value like this: SET VS90COMNTOOLS=%VS100COMNTOOLS% Prior to doing that, I couldn't even get past an Unable to find vcvarsall.bat error. As you can probably tell, I am installing on Windows (XP Pro SP 3) and have Python 2.6.5 and Visual Studio 2010 (full version). Any suggestions? Nick Seigal - Senior GIS Analyst/Application Developer - Lane Council of Governments 859 Willamette Street, Suite 500 - Eugene, Oregon 97401-2910 (541) 682-6733 - (541) 682-4099 (fax) - www.lcog.org Messages to and from this e-mail address may be subject to disclosure under Oregon Public Records Law. * Please consider the environment before printing this message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From planders at gmail.com Wed Jan 30 16:14:36 2013 From: planders at gmail.com (Preston Landers) Date: Wed, 30 Jan 2013 09:14:36 -0600 Subject: [python-win32] building pywin32 for python 2.6... In-Reply-To: <506F591A54F21D4480EE337F77369C050AD5000709@LCEXG03.lc100.net> References: <506F591A54F21D4480EE337F77369C050AD5000709@LCEXG03.lc100.net> Message-ID: I thought you had to have Visual Studio 2008 to build Python 2.6 and extensions. You might want to confirm that VS 2010 is supported for the releases you're using. Failure to find vcvarsall.bat can be caused if you're trying to run this from a regular windows command line. Try launching the Visual Studio version of command prompt. It should set the paths to let you find vcvarsall. Good luck, Preston On Wed, Jan 30, 2013 at 8:29 AM, SEIGAL Nick wrote: > I am trying to get pywin32 build 218 installed and am having trouble. Here > is the error I am getting: > > C:\Python26>python F:\Downloads\Python\pywin32\pywin32-218\setup.py install > Building pywin32 2.6.218.0 > running install > running build > running build_py > running build_ext > Found version 0x601 in C:\Program Files\Microsoft > SDKs\Windows\v7.0A\include\SDKDDKVER.H > building 'perfmondata' extension > C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mc.exe -h > win32\src\perfmon -r build\temp.win32-2.6\Release\win32\src\ > perfmon win32\src\perfmon\PyPerfMsgs.mc > MC: Compiling win32\src\perfmon\PyPerfMsgs.mc > C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\rc.exe > /fobuild\temp.win32-2.6\Release\win32\src\perfmon\PyPerfMsgs.re > s build\temp.win32-2.6\Release\win32\src\perfmon\PyPerfMsgs.rc > Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385 > Copyright (C) Microsoft Corporation. All rights reserved. > > C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox > /MD /W3 /GS- /DNDEBUG -DDISTUTILS_BUILD -D_CR > T_SECURE_NO_WARNINGS -Icom/win32com/src/include -Iwin32/src > -IC:\Python26\include -IC:\Python26\PC "-IC:\Program Files\M > icrosoft SDKs\Windows\v7.0A\include" /Tpwin32\src\perfmon\perfmondata.cpp > /Fobuild\temp.win32-2.6\Release\win32\src\perf > mon\perfmondata.obj /Zi /Fdbuild\temp.win32-2.6\Release\perfmondata_vc.pdb > /EHsc /DMFC_OCC_IMPL_H=\"..\src\occimpl.h\" / > DUNICODE /D_UNICODE /DWINNT > perfmondata.cpp > win32\src\perfmon\perfmondata.cpp(11) : fatal error C1083: Cannot open > include file: 'perfutil.h': No such file or direc > tory > error: command '"C:\Program Files\Microsoft Visual Studio > 10.0\VC\BIN\cl.exe"' failed with exit status 2 > > I had followed a forum suggestion to set a VS90COMNTOOLS environmental > variable to my VS2010 VS100COMNTOOLS value like this: > > SET VS90COMNTOOLS=%VS100COMNTOOLS% > Prior to doing that, I couldn?t even get past an Unable to find > vcvarsall.bat error. > > As you can probably tell, I am installing on Windows (XP Pro SP 3) and have > Python 2.6.5 and Visual Studio 2010 (full version). > > Any suggestions? > > Nick Seigal - Senior GIS Analyst/Application Developer - Lane Council of > Governments > 859 Willamette Street, Suite 500 - Eugene, Oregon 97401-2910 > (541) 682-6733 - (541) 682-4099 (fax) - www.lcog.org > Messages to and from this e-mail address may be subject to disclosure under > Oregon Public Records Law. > ? Please consider the environment before printing this message. > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From malaclypse2 at gmail.com Wed Jan 30 16:26:31 2013 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 30 Jan 2013 10:26:31 -0500 Subject: [python-win32] building pywin32 for python 2.6... In-Reply-To: <506F591A54F21D4480EE337F77369C050AD5000709@LCEXG03.lc100.net> References: <506F591A54F21D4480EE337F77369C050AD5000709@LCEXG03.lc100.net> Message-ID: On Wed, Jan 30, 2013 at 9:29 AM, SEIGAL Nick wrote: > I am trying to get pywin32 build 218 installed and am having trouble. Here > is the error I am getting: ... > Any suggestions? Install using one of the installers from http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/ instead of building from source? -- Jerry From timr at probo.com Wed Jan 30 18:54:40 2013 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Jan 2013 09:54:40 -0800 Subject: [python-win32] OpenDataSource failed inms-word-mail-merge-automation In-Reply-To: <360FC6984C33144EBC925A08B7CD49FE040D61@CCITPEMS6.tpe.compalcomm.com> References: <360FC6984C33144EBC925A08B7CD49FE0405EE@CCITPEMS6.tpe.compalcomm.com> <51080E0E.6040402@probo.com> <360FC6984C33144EBC925A08B7CD49FE040D61@CCITPEMS6.tpe.compalcomm.com> Message-ID: <51095E60.5050400@probo.com> Hsu. Victor (GSM) wrote: > I fixed it by doing some modification. > > data_source_name = os.path.abspath('recipient.csv') > mm.OpenDataSource(data_source_name) > > And the "Word Merge To Document" function works now. > However, my intention is to send an email. So I change some setting, > > #send the merge result to Email > mm.Destination = win32com.client.constants.wdSendToEmail > #send the merge result to document > #mm.Destination = win32com.client.constants.wdSendToNewDocument > mm.MailSubject = "This is a test mail from Python Win32---"+time.strftime('%Y_%m_%d') > > but now, it failed to run again. > ================== > F:\MyProgram\python\Word2Email>python Word2Email.py > Traceback (most recent call last): > File "Word2Email.py", line 41, in > mm.Execute() > File "F:\Python27\lib\site-packages\win32com\gen_py\00020905-0000-0000-C000-00 > 0000000046x0x8x5.py", line 14162, in Execute > return self._oleobj_.InvokeTypes(105, LCID, 1, (24, 0), ((16396, 17),),Pause > > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word' > , u'\u6c92\u6709\u78ba\u5b9a\u5730\u5740\uff0cWord \u7121\u6cd5\u5408\u4f75\u53e > f\u4f9b\u90f5\u5bc4\u6216\u50b3\u771f\u7684\u6587\u4ef6\u3002\u8acb\u9078\u64c7 > [\u8a2d\u5b9a] \u6309\u9215\uff0c\u9078\u53d6\u90f5\u5bc4\u5730\u5740\u8cc7\u659 > 9\u6b04\u4f4d\u3002', u'wdmain11.chm', 25110, -2146822658), None) -2146822658 is 0x800A15FE, which is "Word cannot merge documents that can be distributed by mail or fax without a valid mail address." My guess is that's what the Unicode string in there is trying to tell you. Where did you expect the email to go? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From marcelo.cra at hotmail.com Wed Jan 30 19:21:17 2013 From: marcelo.cra at hotmail.com (Marcelo Almeida) Date: Wed, 30 Jan 2013 16:21:17 -0200 Subject: [python-win32] win32print not printing In-Reply-To: References: Message-ID: After experiment with several options, I "discovered" one that works the way I want (actually just altered a bit Tim Golden's code). It is a workaround, but do the job nicely. import win32ui VALUE = 100 X=50; Y=50 my_multiline_string = string.split() hDC = win32ui.CreateDC () hDC.CreatePrinterDC (my_printer_name) hDC.StartDoc (my_doc_name) hDC.StartPage () for line in my_multiline_string: hDC.TextOut (x, y, line) y += VALUE hDC.EndPage () hDC.EndDoc () Here is the documentation for the DC handlerand for the Textout method. Thanks again for the help! -------------- next part -------------- An HTML attachment was scrubbed... URL: