From joshuar@isogen.com Mon Mar 4 21:00:31 2002 From: joshuar@isogen.com (Joshua Reynolds) Date: Mon, 04 Mar 2002 15:00:31 -0600 Subject: [python-win32] COM, Acrobat and JavaScript Message-ID: <3C83E06F.9090306@isogen.com> Problem: The functionality that I need to use from Acrobat is on a javascript object (returned type defined in the Automation interface as an LDispatch*). I haven't had any problems using any of their other OLE components through python, but when I try to use the root javascript object -- or any other javascript objects accessed through it. I can get at all of the attributes on the javascript objects, but if I try to call a method on it, it fails. Here is the full calling sequence that brings me to failure >>> from win32com.client import Dispatch >>> app = Dispatch("AcroExch.App") >>> app >>> pddoc = Dispatch("AcroExch.PDdoc") >>> pddoc.Open("d:\\tmp\\cn_final.pdf") 1 >>> jso = pddoc.getJsobject >>> jso > >>> jso.app.formsVersion 5.0 >>> jso.console.Show Traceback (most recent call last): File "", line 1, in ? File "D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py", line 432, in __getattr__ raise pythoncom.com_error, details com_error: (-2147467263, 'Not implemented', None, None) in the above, app.formsVersion is an attribute, and console.Show is a parameterless method. Here are some potentially useful snippets from the Acrobat docs on using the JSObject in Visual Basic. 6. JSObject always returns values as Variants. This includes property gets as well as return values from method calls. An empty Variant is used when a null return value is expected. When JSObject returns an array, each element in the array is a Variant. To determine the actual data type of a Variant, use the utility functions IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information module of the VBA library. 7. JSObject can process most elemental Visual Basic types for property puts and input parameters to method calls, including Variant, Array, Boolean, String, Date, Double, Long, Integer, and Byte. JSObject can accept Object parameters, but only when the Object was the result of a property get or method call to a JSObject. JSObject fails to accept values of type Error and Currency. I have verified that I can access the methods on JSObject as well as subObjects, but I would really really like to be able to use this stuff through python. Any ideas on how i can get access to any of those methods? Thanks, Joshua -- Joshua Reynolds | Consultant Isogen International Office: 512-302-9879 Main: 512-380-0347 Cell: 512-743-3865 1016 La Posada Suite 240 Austin, TX 78752 From toodles@yifan.net Tue Mar 5 05:18:04 2002 From: toodles@yifan.net (Andy W) Date: Tue, 5 Mar 2002 13:18:04 +0800 Subject: [python-win32] SendMessage & WM_SYSKEYDOWN (Newbie) Message-ID: <001301c1c405$220c0c20$3100a8c0@sun> Hi, I am quite new to using the win32 programming, and would love some answers. I am making a program that sends key and mouse messages to a window external to it. I have managed to send WM_KEYDOWN, WM_CHAR and WM_KEYUP messages successfully, as well as other non keyboard-related messages. The program whose window that I wish to send messages to has customisable hot-keys. ALT-P is one of them. I have looked through the win32gui documents, and also have searched on the web. I found some websites saying that I should send a WM_SYSKEYDOWN message. It was a little vague, and in VB, so as a newbie I wasn't terribly confident in getting the right result. I did the following: win32gui.SendMessage(hWnd, WM_SYSKEYDOWN, ord("P"), 0) This did nothing. Another website I looked at told me to set the 29th bit of lparam. I did this, but still nothing... Can someone please show how I should send such a message. I also would like to do add control & shift modifiers, and have combinations. If this request generates an "RTFM" reply, could someone please point me to the "FM". Thanks, Andy W From mhammond@skippinet.com.au Tue Mar 5 05:40:00 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 5 Mar 2002 16:40:00 +1100 Subject: [python-win32] COM, Acrobat and JavaScript In-Reply-To: <3C83E06F.9090306@isogen.com> Message-ID: Try running makepy over the Acrobat type library. Look for documentation on makepy in the COM readme. Mark, > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Joshua Reynolds > Sent: Tuesday, 5 March 2002 8:01 AM > To: python-win32 > Subject: [python-win32] COM, Acrobat and JavaScript > > > > > Problem: > > The functionality that I need to use from Acrobat is on a javascript > object (returned type defined in the Automation interface as an > LDispatch*). I haven't had any problems using any of their other OLE > components through python, but when I try to use the root javascript > object -- or any other javascript objects accessed through it. > > I can get at all of the attributes on the javascript objects, but if I > try to call a method on it, it fails. > > Here is the full calling sequence that brings me to failure > > >>> from win32com.client import Dispatch > >>> app = Dispatch("AcroExch.App") > >>> app > > >>> pddoc = Dispatch("AcroExch.PDdoc") > >>> pddoc.Open("d:\\tmp\\cn_final.pdf") > 1 > >>> jso = pddoc.getJsobject > >>> jso > > > >>> jso.app.formsVersion > 5.0 > >>> jso.console.Show > Traceback (most recent call last): > File "", line 1, in ? > File > "D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py", > line 432, in __getattr__ > raise pythoncom.com_error, details > com_error: (-2147467263, 'Not implemented', None, None) > > in the above, app.formsVersion is an attribute, and console.Show is a > parameterless method. > > Here are some potentially useful snippets from the Acrobat docs on using > the JSObject in Visual Basic. > > > > 6. JSObject always returns values as Variants. This includes property > gets as well as > return values from method calls. An empty Variant is used when a null > return value > is expected. When JSObject returns an array, each element in the array > is a > Variant. To determine the actual data type of a Variant, use the utility > functions > IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information > module of the VBA library. > 7. JSObject can process most elemental Visual Basic types for property > puts and > input parameters to method calls, including Variant, Array, Boolean, > String, Date, > Double, Long, Integer, and Byte. JSObject can accept Object parameters, > but only > when the Object was the result of a property get or method call to a > JSObject. > JSObject fails to accept values of type Error and Currency. > > I have verified that I can access the methods on JSObject as well as > subObjects, but I would really really like to be able to use this stuff > through python. > > Any ideas on how i can get access to any of those methods? > > > > Thanks, > Joshua > > > > -- > Joshua Reynolds | Consultant > > Isogen International > Office: 512-302-9879 > Main: 512-380-0347 > Cell: 512-743-3865 > 1016 La Posada Suite 240 > Austin, TX 78752 > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond@skippinet.com.au Tue Mar 5 05:42:02 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 5 Mar 2002 16:42:02 +1100 Subject: [python-win32] SendMessage & WM_SYSKEYDOWN (Newbie) In-Reply-To: <001301c1c405$220c0c20$3100a8c0@sun> Message-ID: This problem is more a generic Win32 problem than a Python one. Eg, it may be as simple as sending a WM_SYSKEYUP after the key down message. Try and find the answer for *any* language. Then, once we know we have a technique that works, we can implement it in Python. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Andy W > Sent: Tuesday, 5 March 2002 4:18 PM > To: python-win32 > Subject: [python-win32] SendMessage & WM_SYSKEYDOWN (Newbie) > > > Hi, > > I am quite new to using the win32 programming, and would love > some answers. > > I am making a program that sends key and mouse messages to a > window external > to it. I have managed to send WM_KEYDOWN, WM_CHAR and WM_KEYUP messages > successfully, as well as other non keyboard-related messages. > The program whose window that I wish to send messages to has customisable > hot-keys. ALT-P is one of them. I have looked through the win32gui > documents, and also have searched on the web. I found some websites saying > that I should send a WM_SYSKEYDOWN message. It was a little vague, and in > VB, so as a newbie I wasn't terribly confident in getting the > right result. > > I did the following: > win32gui.SendMessage(hWnd, WM_SYSKEYDOWN, ord("P"), 0) > > This did nothing. Another website I looked at told me to set the > 29th bit of > lparam. I did this, but still nothing... > > Can someone please show how I should send such a message. I also > would like > to do add control & shift modifiers, and have combinations. > If this request generates an "RTFM" reply, could someone please > point me to > the "FM". > > Thanks, > Andy W > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From joshuar@isogen.com Tue Mar 5 15:43:01 2002 From: joshuar@isogen.com (Joshua Reynolds) Date: Tue, 05 Mar 2002 09:43:01 -0600 Subject: [python-win32] COM, Acrobat and JavaScript References: Message-ID: <3C84E785.4040001@isogen.com> I've already tried that and it doesn't seem to get me anything. I run makepy and it generates the file, but when I print out the objects I get they are still or >. In the Acrobat documentation they say they don't define any interface for the JSObject, just use IDispatch. I don't know if this helps, but the only difference I can tell between the JSObject and any of their other interfaces etc. is that the JSOBject return type from the getJSOBject call is defined as LDispatch* (is this a typo and supposed to say LPDispatch*) whereas all of the other com objects are returned as types LPDispatch (no *). I am kind of blissfully ignorant of the magic that is going on in the python com mapping. Oh yeah, I am running Python 2.2 with the build 146. Any other suggestions? Thanks a million, Joshua Mark Hammond wrote: > Try running makepy over the Acrobat type library. Look for documentation on > makepy in the COM readme. > > Mark, > > >>-----Original Message----- >>From: python-win32-admin@python.org >>[mailto:python-win32-admin@python.org]On Behalf Of Joshua Reynolds >>Sent: Tuesday, 5 March 2002 8:01 AM >>To: python-win32 >>Subject: [python-win32] COM, Acrobat and JavaScript >> >> >> >> >>Problem: >> >>The functionality that I need to use from Acrobat is on a javascript >>object (returned type defined in the Automation interface as an >>LDispatch*). I haven't had any problems using any of their other OLE >>components through python, but when I try to use the root javascript >>object -- or any other javascript objects accessed through it. >> >>I can get at all of the attributes on the javascript objects, but if I >>try to call a method on it, it fails. >> >>Here is the full calling sequence that brings me to failure >> >> >>> from win32com.client import Dispatch >> >>> app = Dispatch("AcroExch.App") >> >>> app >> >> >>> pddoc = Dispatch("AcroExch.PDdoc") >> >>> pddoc.Open("d:\\tmp\\cn_final.pdf") >>1 >> >>> jso = pddoc.getJsobject >> >>> jso >>> >> >>> jso.app.formsVersion >>5.0 >> >>> jso.console.Show >>Traceback (most recent call last): >> File "", line 1, in ? >> File >>"D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py", >>line 432, in __getattr__ >> raise pythoncom.com_error, details >>com_error: (-2147467263, 'Not implemented', None, None) >> >>in the above, app.formsVersion is an attribute, and console.Show is a >>parameterless method. >> >>Here are some potentially useful snippets from the Acrobat docs on using >>the JSObject in Visual Basic. >> >> >> >>6. JSObject always returns values as Variants. This includes property >>gets as well as >>return values from method calls. An empty Variant is used when a null >>return value >>is expected. When JSObject returns an array, each element in the array >>is a >>Variant. To determine the actual data type of a Variant, use the utility >>functions >>IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information >>module of the VBA library. >>7. JSObject can process most elemental Visual Basic types for property >>puts and >>input parameters to method calls, including Variant, Array, Boolean, >>String, Date, >>Double, Long, Integer, and Byte. JSObject can accept Object parameters, >>but only >>when the Object was the result of a property get or method call to a >>JSObject. >>JSObject fails to accept values of type Error and Currency. >> >>I have verified that I can access the methods on JSObject as well as >>subObjects, but I would really really like to be able to use this stuff >>through python. >> >>Any ideas on how i can get access to any of those methods? >> >> >> >>Thanks, >>Joshua >> >> >> >>-- >>Joshua Reynolds | Consultant >> >>Isogen International >>Office: 512-302-9879 >>Main: 512-380-0347 >>Cell: 512-743-3865 >>1016 La Posada Suite 240 >>Austin, TX 78752 >> >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 >> > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > -- Joshua Reynolds | Consultant Isogen International Office: 512-302-9879 Main: 512-380-0347 Cell: 512-743-3865 1016 La Posada Suite 240 Austin, TX 78752 From mhammond@skippinet.com.au Tue Mar 5 22:51:14 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Wed, 6 Mar 2002 09:51:14 +1100 Subject: [python-win32] COM, Acrobat and JavaScript In-Reply-To: <3C84E785.4040001@isogen.com> Message-ID: The other alternative is to modify win32com\client\dynamic.py. Near the top of the file, find the list ERRORS_BAD_CONTEXT. Try adding winerror.E_NOTIMPL to this list and see if it solves the problem. Mark. > -----Original Message----- > From: Joshua Reynolds [mailto:joshuar@isogen.com] > Sent: Wednesday, 6 March 2002 2:43 AM > To: Mark Hammond > Cc: python-win32@python.org > Subject: Re: [python-win32] COM, Acrobat and JavaScript > > > I've already tried that and it doesn't seem to get me anything. I run > makepy and it generates the file, but when I print out the objects I get > they are still or >. > > In the Acrobat documentation they say they don't define any interface > for the JSObject, just use IDispatch. I don't know if this helps, but > the only difference I can tell between the JSObject and any of their > other interfaces etc. is that the JSOBject return type from the > getJSOBject call is defined as LDispatch* (is this a typo and supposed > to say LPDispatch*) whereas all of the other com objects are returned as > types LPDispatch (no *). I am kind of blissfully ignorant of the magic > that is going on in the python com mapping. > > Oh yeah, I am running Python 2.2 with the build 146. > > Any other suggestions? > > Thanks a million, > > Joshua > > Mark Hammond wrote: > > Try running makepy over the Acrobat type library. Look for > documentation on > > makepy in the COM readme. > > > > Mark, > > > > > >>-----Original Message----- > >>From: python-win32-admin@python.org > >>[mailto:python-win32-admin@python.org]On Behalf Of Joshua Reynolds > >>Sent: Tuesday, 5 March 2002 8:01 AM > >>To: python-win32 > >>Subject: [python-win32] COM, Acrobat and JavaScript > >> > >> > >> > >> > >>Problem: > >> > >>The functionality that I need to use from Acrobat is on a javascript > >>object (returned type defined in the Automation interface as an > >>LDispatch*). I haven't had any problems using any of their other OLE > >>components through python, but when I try to use the root javascript > >>object -- or any other javascript objects accessed through it. > >> > >>I can get at all of the attributes on the javascript objects, but if I > >>try to call a method on it, it fails. > >> > >>Here is the full calling sequence that brings me to failure > >> > >> >>> from win32com.client import Dispatch > >> >>> app = Dispatch("AcroExch.App") > >> >>> app > >> > >> >>> pddoc = Dispatch("AcroExch.PDdoc") > >> >>> pddoc.Open("d:\\tmp\\cn_final.pdf") > >>1 > >> >>> jso = pddoc.getJsobject > >> >>> jso > >>> > >> >>> jso.app.formsVersion > >>5.0 > >> >>> jso.console.Show > >>Traceback (most recent call last): > >> File "", line 1, in ? > >> File > >>"D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py", > >>line 432, in __getattr__ > >> raise pythoncom.com_error, details > >>com_error: (-2147467263, 'Not implemented', None, None) > >> > >>in the above, app.formsVersion is an attribute, and console.Show is a > >>parameterless method. > >> > >>Here are some potentially useful snippets from the Acrobat docs on using > >>the JSObject in Visual Basic. > >> > >> > >> > >>6. JSObject always returns values as Variants. This includes property > >>gets as well as > >>return values from method calls. An empty Variant is used when a null > >>return value > >>is expected. When JSObject returns an array, each element in the array > >>is a > >>Variant. To determine the actual data type of a Variant, use the utility > >>functions > >>IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information > >>module of the VBA library. > >>7. JSObject can process most elemental Visual Basic types for property > >>puts and > >>input parameters to method calls, including Variant, Array, Boolean, > >>String, Date, > >>Double, Long, Integer, and Byte. JSObject can accept Object parameters, > >>but only > >>when the Object was the result of a property get or method call to a > >>JSObject. > >>JSObject fails to accept values of type Error and Currency. > >> > >>I have verified that I can access the methods on JSObject as well as > >>subObjects, but I would really really like to be able to use this stuff > >>through python. > >> > >>Any ideas on how i can get access to any of those methods? > >> > >> > >> > >>Thanks, > >>Joshua > >> > >> > >> > >>-- > >>Joshua Reynolds | Consultant > >> > >>Isogen International > >>Office: 512-302-9879 > >>Main: 512-380-0347 > >>Cell: 512-743-3865 > >>1016 La Posada Suite 240 > >>Austin, TX 78752 > >> > >> > >>_______________________________________________ > >>Python-win32 mailing list > >>Python-win32@python.org > >>http://mail.python.org/mailman/listinfo/python-win32 > >> > > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > -- > Joshua Reynolds | Consultant > > Isogen International > Office: 512-302-9879 > Main: 512-380-0347 > Cell: 512-743-3865 > 1016 La Posada Suite 240 > Austin, TX 78752 > From joshuar@isogen.com Wed Mar 6 16:02:34 2002 From: joshuar@isogen.com (Joshua Reynolds) Date: Wed, 06 Mar 2002 10:02:34 -0600 Subject: [python-win32] COM, Acrobat and JavaScript References: Message-ID: <3C863D9A.7000707@isogen.com> That worked. What is this list for? Thanks for your help, Joshua Mark Hammond wrote: > The other alternative is to modify win32com\client\dynamic.py. Near the top > of the file, find the list ERRORS_BAD_CONTEXT. Try adding > winerror.E_NOTIMPL to this list and see if it solves the problem. > > Mark. > > >>-----Original Message----- >>From: Joshua Reynolds [mailto:joshuar@isogen.com] >>Sent: Wednesday, 6 March 2002 2:43 AM >>To: Mark Hammond >>Cc: python-win32@python.org >>Subject: Re: [python-win32] COM, Acrobat and JavaScript >> >> >>I've already tried that and it doesn't seem to get me anything. I run >>makepy and it generates the file, but when I print out the objects I get >>they are still or >. >> >>In the Acrobat documentation they say they don't define any interface >>for the JSObject, just use IDispatch. I don't know if this helps, but >>the only difference I can tell between the JSObject and any of their >>other interfaces etc. is that the JSOBject return type from the >>getJSOBject call is defined as LDispatch* (is this a typo and supposed >>to say LPDispatch*) whereas all of the other com objects are returned as >>types LPDispatch (no *). I am kind of blissfully ignorant of the magic >>that is going on in the python com mapping. >> >>Oh yeah, I am running Python 2.2 with the build 146. >> >>Any other suggestions? >> >>Thanks a million, >> >>Joshua >> >>Mark Hammond wrote: >> >>>Try running makepy over the Acrobat type library. Look for >>> >>documentation on >> >>>makepy in the COM readme. >>> >>>Mark, >>> >>> >>> >>>>-----Original Message----- >>>>From: python-win32-admin@python.org >>>>[mailto:python-win32-admin@python.org]On Behalf Of Joshua Reynolds >>>>Sent: Tuesday, 5 March 2002 8:01 AM >>>>To: python-win32 >>>>Subject: [python-win32] COM, Acrobat and JavaScript >>>> >>>> >>>> >>>> >>>>Problem: >>>> >>>>The functionality that I need to use from Acrobat is on a javascript >>>>object (returned type defined in the Automation interface as an >>>>LDispatch*). I haven't had any problems using any of their other OLE >>>>components through python, but when I try to use the root javascript >>>>object -- or any other javascript objects accessed through it. >>>> >>>>I can get at all of the attributes on the javascript objects, but if I >>>>try to call a method on it, it fails. >>>> >>>>Here is the full calling sequence that brings me to failure >>>> >>>> >>>>>>>from win32com.client import Dispatch >>>>>>>app = Dispatch("AcroExch.App") >>>>>>>app >>>>>>> >>>> >>>> >>>>>>>pddoc = Dispatch("AcroExch.PDdoc") >>>>>>>pddoc.Open("d:\\tmp\\cn_final.pdf") >>>>>>> >>>>1 >>>> >>>>>>>jso = pddoc.getJsobject >>>>>>>jso >>>>>>> >>>>> >>>> >>>>>>>jso.app.formsVersion >>>>>>> >>>>5.0 >>>> >>>>>>>jso.console.Show >>>>>>> >>>>Traceback (most recent call last): >>>> File "", line 1, in ? >>>> File >>>>"D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py", >>>>line 432, in __getattr__ >>>> raise pythoncom.com_error, details >>>>com_error: (-2147467263, 'Not implemented', None, None) >>>> >>>>in the above, app.formsVersion is an attribute, and console.Show is a >>>>parameterless method. >>>> >>>>Here are some potentially useful snippets from the Acrobat docs on using >>>>the JSObject in Visual Basic. >>>> >>>> >>>> >>>>6. JSObject always returns values as Variants. This includes property >>>>gets as well as >>>>return values from method calls. An empty Variant is used when a null >>>>return value >>>>is expected. When JSObject returns an array, each element in the array >>>>is a >>>>Variant. To determine the actual data type of a Variant, use the utility >>>>functions >>>>IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information >>>>module of the VBA library. >>>>7. JSObject can process most elemental Visual Basic types for property >>>>puts and >>>>input parameters to method calls, including Variant, Array, Boolean, >>>>String, Date, >>>>Double, Long, Integer, and Byte. JSObject can accept Object parameters, >>>>but only >>>>when the Object was the result of a property get or method call to a >>>>JSObject. >>>>JSObject fails to accept values of type Error and Currency. >>>> >>>>I have verified that I can access the methods on JSObject as well as >>>>subObjects, but I would really really like to be able to use this stuff >>>>through python. >>>> >>>>Any ideas on how i can get access to any of those methods? >>>> >>>> >>>> >>>>Thanks, >>>>Joshua >>>> >>>> >>>> >>>>-- >>>>Joshua Reynolds | Consultant >>>> >>>>Isogen International >>>>Office: 512-302-9879 >>>>Main: 512-380-0347 >>>>Cell: 512-743-3865 >>>>1016 La Posada Suite 240 >>>>Austin, TX 78752 >>>> >>>> >>>>_______________________________________________ >>>>Python-win32 mailing list >>>>Python-win32@python.org >>>>http://mail.python.org/mailman/listinfo/python-win32 >>>> >>>> >>> >>>_______________________________________________ >>>Python-win32 mailing list >>>Python-win32@python.org >>>http://mail.python.org/mailman/listinfo/python-win32 >>> >>> >>> >>> >> >>-- >>Joshua Reynolds | Consultant >> >>Isogen International >>Office: 512-302-9879 >>Main: 512-380-0347 >>Cell: 512-743-3865 >>1016 La Posada Suite 240 >>Austin, TX 78752 >> >> > > > -- Joshua Reynolds ISOGEN International, LLC 1016 La Posada Suite 240 Austin, TX 78752 Main: +(1) 512-380-0347 Office: +(1) 512-302-9879 Fax: +(1) 512-380-0429 Cell: +(1) 512-743-3865 From joshuar@isogen.com Wed Mar 6 16:44:33 2002 From: joshuar@isogen.com (Joshua Reynolds) Date: Wed, 06 Mar 2002 10:44:33 -0600 Subject: [python-win32] COM, Acrobat and JavaScript References: <3C863D9A.7000707@isogen.com> Message-ID: <3C864771.3030308@isogen.com> -- from dynamic.py # These errors generally mean the property or method exists, # but can't be used in this context - eg, property instead of a method, etc. # Used to determine if we have a real error or not. -- end Sorry, I guess I should read the comment before I post. So if one of these errors occurs during a dynamic attribute lookup, is there some sort of secondary lookup that is tried? J Joshua Reynolds wrote: > That worked. What is this list for? > > Thanks for your help, > > Joshua > > Mark Hammond wrote: > >> The other alternative is to modify win32com\client\dynamic.py. Near >> the top >> of the file, find the list ERRORS_BAD_CONTEXT. Try adding >> winerror.E_NOTIMPL to this list and see if it solves the problem. >> >> Mark. >> >> >>> -----Original Message----- >>> From: Joshua Reynolds [mailto:joshuar@isogen.com] >>> Sent: Wednesday, 6 March 2002 2:43 AM >>> To: Mark Hammond >>> Cc: python-win32@python.org >>> Subject: Re: [python-win32] COM, Acrobat and JavaScript >>> >>> >>> I've already tried that and it doesn't seem to get me anything. I run >>> makepy and it generates the file, but when I print out the objects I get >>> they are still or >. >>> >>> In the Acrobat documentation they say they don't define any interface >>> for the JSObject, just use IDispatch. I don't know if this helps, but >>> the only difference I can tell between the JSObject and any of their >>> other interfaces etc. is that the JSOBject return type from the >>> getJSOBject call is defined as LDispatch* (is this a typo and supposed >>> to say LPDispatch*) whereas all of the other com objects are returned as >>> types LPDispatch (no *). I am kind of blissfully ignorant of the magic >>> that is going on in the python com mapping. >>> >>> Oh yeah, I am running Python 2.2 with the build 146. >>> >>> Any other suggestions? >>> >>> Thanks a million, >>> >>> Joshua >>> >>> Mark Hammond wrote: >>> >>>> Try running makepy over the Acrobat type library. Look for >>>> >>> documentation on >>> >>>> makepy in the COM readme. >>>> >>>> Mark, >>>> >>>> >>>> >>>>> -----Original Message----- >>>>> From: python-win32-admin@python.org >>>>> [mailto:python-win32-admin@python.org]On Behalf Of Joshua Reynolds >>>>> Sent: Tuesday, 5 March 2002 8:01 AM >>>>> To: python-win32 >>>>> Subject: [python-win32] COM, Acrobat and JavaScript >>>>> >>>>> >>>>> >>>>> >>>>> Problem: >>>>> >>>>> The functionality that I need to use from Acrobat is on a javascript >>>>> object (returned type defined in the Automation interface as an >>>>> LDispatch*). I haven't had any problems using any of their other OLE >>>>> components through python, but when I try to use the root javascript >>>>> object -- or any other javascript objects accessed through it. >>>>> >>>>> I can get at all of the attributes on the javascript objects, but if I >>>>> try to call a method on it, it fails. >>>>> >>>>> Here is the full calling sequence that brings me to failure >>>>> >>>>> >>>>>>>> from win32com.client import Dispatch >>>>>>>> app = Dispatch("AcroExch.App") >>>>>>>> app >>>>>>>> >>>>> >>>>> >>>>>>>> pddoc = Dispatch("AcroExch.PDdoc") >>>>>>>> pddoc.Open("d:\\tmp\\cn_final.pdf") >>>>>>>> >>>>> 1 >>>>> >>>>>>>> jso = pddoc.getJsobject >>>>>>>> jso >>>>>>>> >>>>> > >>>>> >>>>>>>> jso.app.formsVersion >>>>>>>> >>>>> 5.0 >>>>> >>>>>>>> jso.console.Show >>>>>>>> >>>>> Traceback (most recent call last): >>>>> File "", line 1, in ? >>>>> File >>>>> "D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py", >>>>> line 432, in __getattr__ >>>>> raise pythoncom.com_error, details >>>>> com_error: (-2147467263, 'Not implemented', None, None) >>>>> >>>>> in the above, app.formsVersion is an attribute, and console.Show is a >>>>> parameterless method. >>>>> >>>>> Here are some potentially useful snippets from the Acrobat docs on >>>>> using >>>>> the JSObject in Visual Basic. >>>>> >>>>> >>>>> >>>>> 6. JSObject always returns values as Variants. This includes property >>>>> gets as well as >>>>> return values from method calls. An empty Variant is used when a null >>>>> return value >>>>> is expected. When JSObject returns an array, each element in the array >>>>> is a >>>>> Variant. To determine the actual data type of a Variant, use the >>>>> utility >>>>> functions >>>>> IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the >>>>> Information >>>>> module of the VBA library. >>>>> 7. JSObject can process most elemental Visual Basic types for property >>>>> puts and >>>>> input parameters to method calls, including Variant, Array, Boolean, >>>>> String, Date, >>>>> Double, Long, Integer, and Byte. JSObject can accept Object >>>>> parameters, >>>>> but only >>>>> when the Object was the result of a property get or method call to a >>>>> JSObject. >>>>> JSObject fails to accept values of type Error and Currency. >>>>> >>>>> I have verified that I can access the methods on JSObject as well as >>>>> subObjects, but I would really really like to be able to use this >>>>> stuff >>>>> through python. >>>>> >>>>> Any ideas on how i can get access to any of those methods? >>>>> >>>>> >>>>> >>>>> Thanks, >>>>> Joshua >>>>> >>>>> >>>>> >>>>> -- >>>>> Joshua Reynolds | Consultant >>>>> >>>>> Isogen International >>>>> Office: 512-302-9879 >>>>> Main: 512-380-0347 >>>>> Cell: 512-743-3865 >>>>> 1016 La Posada Suite 240 >>>>> Austin, TX 78752 >>>>> >>>>> >>>>> _______________________________________________ >>>>> Python-win32 mailing list >>>>> Python-win32@python.org >>>>> http://mail.python.org/mailman/listinfo/python-win32 >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> Python-win32 mailing list >>>> Python-win32@python.org >>>> http://mail.python.org/mailman/listinfo/python-win32 >>>> >>>> >>>> >>>> >>> >>> -- >>> Joshua Reynolds | Consultant >>> >>> Isogen International >>> Office: 512-302-9879 >>> Main: 512-380-0347 >>> Cell: 512-743-3865 >>> 1016 La Posada Suite 240 >>> Austin, TX 78752 >>> >>> >> >> >> > > -- Joshua Reynolds ISOGEN International, LLC 1016 La Posada Suite 240 Austin, TX 78752 Main: +(1) 512-380-0347 Office: +(1) 512-302-9879 Fax: +(1) 512-380-0429 Cell: +(1) 512-743-3865 From Jim.Vickroy@noaa.gov Wed Mar 6 18:56:07 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Wed, 06 Mar 2002 11:56:07 -0700 Subject: [python-win32] (10093, 'Successful WSAStartup() not yet performed') Message-ID: <3C866647.899BD1F2@noaa.gov> Does anyone know what this message means and/or what the cause might be? It is being generated in a socket-based application (that had been working) by the following statement: transmitter = self.server_socket.accept() # blocks till something arrives where 'transmitter' is expected to be the usual 2-element tuple. From jens.jorgensen@tallan.com Wed Mar 6 19:21:53 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Wed, 06 Mar 2002 13:21:53 -0600 Subject: [python-win32] (10093, 'Successful WSAStartup() not yet performed') References: <3C866647.899BD1F2@noaa.gov> Message-ID: <3C866C51.9010009@tallan.com> The Windows Sockets library has to be initialized (via a call to WSAStartup) before other socket calls may be made. This should be happening automatically though in a python program (I use sockets in many python scripts and have never explicitly called this). If the error happens on accept that's pretty weird since that implies that you've made other sockets calls previous to this and they obviously didn't error. I wonder if there's some way WSACleanup could've been called right before this. In what context does this thing get called? Is this in some regular python program or is it from ActiveScripting or anything like that? I'm just trying to think of some way WSACleanup might've been called prematurely. Jim Vickroy wrote: >Does anyone know what this message means and/or what the cause might be? > >It is being generated in a socket-based application (that had been >working) by the following statement: > > transmitter = self.server_socket.accept() # blocks till >something arrives > >where 'transmitter' is expected to be the usual 2-element tuple. > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com From mhammond@skippinet.com.au Thu Mar 7 03:47:54 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Thu, 7 Mar 2002 14:47:54 +1100 Subject: [python-win32] COM, Acrobat and JavaScript In-Reply-To: <3C864771.3030308@isogen.com> Message-ID: > -- from dynamic.py > # These errors generally mean the property or method exists, > # but can't be used in this context - eg, property instead of a > method, etc. > # Used to determine if we have a real error or not. > -- end > > Sorry, I guess I should read the comment before I post. > So if one of these errors occurs during a dynamic attribute lookup, is > there some sort of secondary lookup that is tried? Yes - it is looked up as a method. We could ignore all errors - but that would mask other real errors. Eg: a = foo.bar If fetching this value raises an exception, then almost certainly we want that exception to be raised as the line above is executed. However, if the exception is really just telling us "hey - you can't fetch a property of that name, but there may actually be a method you can call of that name", then we need to allow it to be used as a method. eg, a = foo.bar() Looks identical to the former without the parens from the POV of the __getattr__ function. So - the key to solving this is to force makepy to work somehow. It appears this object is similar to Lotus Notes - ie, there is a type library, but anonymous COM objects don't tell COM they are described in the type library. Our book describes how to force makepy generated objects to be used, or search deja for references to Lotus Notes, but basically you use something like: mod = gencache.EnsureModule(blah) # instead of # ob = Dispatch("WhateverItIs") ob = mod.Whatever() Properties and methods should then work perfectly. Mark. From Dan.Palmer@sympatico.ca Thu Mar 7 22:50:33 2002 From: Dan.Palmer@sympatico.ca (Dan Palmer) Date: Thu, 7 Mar 2002 17:50:33 -0500 Subject: [python-win32] Deletion of worksheet without the confirmation prompt Message-ID: <002601c1c62a$7d6b61c0$f002a8c0@p2200> This is a multi-part message in MIME format. ------=_NextPart_000_0021_01C1C600.94290360 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable When using win32com how does one delete a sheet from a workbook either = by=20 name or by number without the confirmation dialog prompt.=20 import win32com.client=20 ExcelApp=3D win32com.client.Dispatch("Excel.Application")=20 ExcelApp.Worksheets.Add()=20 sht =3D ExcelApp.Worksheets(1)=20 sht.Delete()=20 at this point it generates a confirmation dialog, if I = acknowledge the=20 dialog it does delete the proper sheet. Is there a way to = turn the=20 confirmation off (either as a preference, or as a parameter = to delete)=20 =20 =20 Thanks in advance ------=_NextPart_000_0021_01C1C600.94290360 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
When using win32com how does one delete a sheet from a workbook = either by=20
name or by number without the confirmation dialog prompt.=20

 
 
import win32com.client
ExcelApp=3D=20 win32com.client.Dispatch("Excel.Application")=20
ExcelApp.Worksheets.Add()
sht =3D ExcelApp.Worksheets(1)=20
sht.Delete()
 
 
at this point it generates a confirmation dialog, = if I=20 acknowledge the
dialog it does delete the proper = sheet.  Is=20 there a way to turn the
confirmation off (either as a=20 preference, or as a parameter to delete)=20 =
=
 
Thanks in advance

------=_NextPart_000_0021_01C1C600.94290360-- From andrew-pywin32@puzzling.org Wed Mar 13 01:49:25 2002 From: andrew-pywin32@puzzling.org (Andrew Bennetts) Date: Wed, 13 Mar 2002 12:49:25 +1100 Subject: [python-win32] Services stopping on logout Message-ID: <20020313014925.GB29051@ritsuko.xware.cx> Hi, I'm having a mysterious problem where Python services are stopping when the user logs out. I *think* this behaviour may have started around the time I upgraded to Python 2.2 / win32all-136. I'm on Windows 2000. Does anyway know how to stop this behaviour? Non-python services work fine. Thanks, -Andrew. From jeff@ccvcorp.com Wed Mar 13 18:54:58 2002 From: jeff@ccvcorp.com (Jeff Shannon) Date: Wed, 13 Mar 2002 10:54:58 -0800 Subject: [python-win32] Services stopping on logout References: Message-ID: <3C8FA082.7DFA7E47@ccvcorp.com> > Andrew Bennetts wrote: > > I'm having a mysterious problem where Python services are stopping when the > user logs out. I *think* this behaviour may have started around the time I > upgraded to Python 2.2 / win32all-136. I'm on Windows 2000. At a semi-random guess, did you install Python2.2 and the service itself as Administrator? If they were installed as a regular user, then I'd expect them to only run while that user is logged in. Jeff Shannon Technician/Programmer Credit International From andrew@puzzling.org Thu Mar 14 01:23:55 2002 From: andrew@puzzling.org (Andrew Bennetts) Date: Thu, 14 Mar 2002 12:23:55 +1100 Subject: [python-win32] Services stopping on logout In-Reply-To: <3C8FA082.7DFA7E47@ccvcorp.com> References: <3C8FA082.7DFA7E47@ccvcorp.com> Message-ID: <20020314012355.GA9480@ritsuko.xware.cx> On Wed, Mar 13, 2002 at 10:54:58AM -0800, Jeff Shannon wrote: > > > Andrew Bennetts wrote: > > > > I'm having a mysterious problem where Python services are stopping when the > > user logs out. I *think* this behaviour may have started around the time I > > upgraded to Python 2.2 / win32all-136. I'm on Windows 2000. > > At a semi-random guess, did you install Python2.2 and the service itself as > Administrator? If they were installed as a regular user, then I'd expect them > to only run while that user is logged in. I did install the service as Administrator, but it appears I did not install Python2.2 as Administrator. I just tried completely uninstalling Python and re-installing it as Administrator, and it works fine now. Thank you! That had me stumped, though it's obvious now that you've pointed it out to me. It strikes me as odd that installing Python as non-Administrator would prevent a service using it from running as Administrator, but if that's the way it has to work, then fair enough. Thanks again. -Andrew. From mbg@apama.com Thu Mar 14 14:55:47 2002 From: mbg@apama.com (Moray B. Grieve) Date: Thu, 14 Mar 2002 14:55:47 -0000 Subject: [python-win32] win32 equivalent for "my.exe > stdout.txt &" Message-ID: <7CD4BE0203A91845A17CE0E8BD9A128930F5ED@UKCAMMS002.msapama.apama.com> This is a multi-part message in MIME format. ------_=_NextPart_001_01C1CB68.5309F756 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > I want to launch a child process from within a python script which = will run in the background with all stdout redirected to a file i.e. a = unix equivalent of "my.exe > stdout.txt &". To do this I have been = trying something like:=20 >=20 >=20 > startupInfo =3D win32process.STARTUPINFO() >=20 > startupInfo.hStdInput =3D win32api.GetStdHandle(STD_INPUT_HANDLE); > startupInfo.hStdError =3D win32api.GetStdHandle(STD_ERR_HANDLE); > startupInfo.hStdOutput =3D win32file.CreateFile("stdout.txt",=20 > win32con.GENERIC_WRITE, > 0,=20 > None,=20 > win32con.CREATE_ALWAYS,=20 > win32con.FILE_FLAG_WRITE_THROUGH,=20 > 0 ) =20 > startupInfo.dwFlags =3D win32con.STARTF_USESTDHANDLES > =20 > hProcess, hThread, dwPid, dwTid =3D win32process.CreateProcess( > None, # appName > "my.exe", # commandLine > None, # processAttributes > None, # threadAttributes > 1, # bInheritHandles > 0, # dwCreationFlags > None, # newEnvironment > None, # currentDirectory > startupInfo # startupInfo > ) >=20 > I was hoping that by setting startupInfo.hStdOutput to the newly = created file handle, writes to stdout by the child process would = automatically be written to file - however this does not seem to tbe the = case. Although stdout does get redirected somewhere, it does not go to = the file and even flushing the handle does not seem to solve the = problem. Am I being to naive in this approach? I have tried all = different flags for the win32file.CreateFile and = win32process.CreateProcess methods. Do I need to set up the child stdout = to a pipe, and manage the read end of the pipe in a thread? I'm a novice = in this area so would appreciate any help. >=20 > Thanks,=20 > Moray Grieve ------_=_NextPart_001_01C1CB68.5309F756 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable win32 equivalent for "my.exe > stdout.txt = &"

I want to launch a child process from = within a python script which will run in the background with all stdout = redirected to a file i.e. a unix equivalent of "my.exe > = stdout.txt &". To do this I have been trying something like: =


startupInfo =3D = win32process.STARTUPINFO()

startupInfo.hStdInput =3D = win32api.GetStdHandle(STD_INPUT_HANDLE);
startupInfo.hStdError =3D = win32api.GetStdHandle(STD_ERR_HANDLE);
startupInfo.hStdOutput =3D = win32file.CreateFile("stdout.txt",
        =         =         =         =               = win32con.GENERIC_WRITE,
        =         =         =         =               0,
        =         =         =         =               None,
        =         =         =         =               win32con.CREATE_ALWAYS, =
        =         =         =         =               = win32con.FILE_FLAG_WRITE_THROUGH,
        =         =         =         =               0 = )    
startupInfo.dwFlags =3D = win32con.STARTF_USESTDHANDLES
       =
hProcess, hThread, dwPid, dwTid =3D = win32process.CreateProcess(
         &nbs= p;  None,        # = appName
         &nbs= p;  "my.exe",  # commandLine
         &nbs= p;  None,        # = processAttributes
         &nbs= p;  None,        # = threadAttributes
         &nbs= p;  = 1,            = ;  # bInheritHandles
         &nbs= p;  = 0,            = ;  # dwCreationFlags
         &nbs= p;  None,        # = newEnvironment
         &nbs= p;  None,        # = currentDirectory
         &nbs= p;  startupInfo # startupInfo
         &nbs= p;  )

I was hoping that by setting = startupInfo.hStdOutput to the newly created file handle, writes to = stdout by the child process would automatically be written to file - = however this does not seem to tbe the case. Although stdout does get = redirected somewhere, it does not go to the file and even flushing the = handle does not seem to solve the problem. Am I being to naive in this = approach? I have tried all different flags for the win32file.CreateFile = and win32process.CreateProcess methods. Do I need to set up the child = stdout to a pipe, and manage the read end of the pipe in a thread? I'm a = novice in this area so would appreciate any help.

Thanks,
Moray Grieve

------_=_NextPart_001_01C1CB68.5309F756-- From noah@sfbags.com Mon Mar 18 19:20:13 2002 From: noah@sfbags.com (Noah Spurrier) Date: Mon, 18 Mar 2002 11:20:13 -0800 Subject: [python-win32] win32 equivalent for "my.exe > stdout.txt &" In-Reply-To: <7CD4BE0203A91845A17CE0E8BD9A128930F5ED@UKCAMMS002.msapama.apama.com> Message-ID: This is a big problem with Windows. I have found it very hard to capture output from a child program that writes to stdout. Is your child process a Python script? You mentioned flushing the buffer, but does the child process flush stdout (sys.stdout.flush() ) or did you mean that the parent flushes it? When your child terminates and the parent closes the file does it get written? Make sure the parent actually closes the file. I have had problems with files that are not explicitly closed. Windows also has a whole API dedicated to Console applications. It's horrible. I spent a lot of time fiddling with it. It looked like it would do what I needed, but it turned out to be a bad trail. But if you are adventurous then look for "Character-Mode Applications" and "Console Reference" on MSDN. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/conchar_5ehx.asp You might also trying talking to the guy that maintains the Windows version of Expect: http://bmrc.berkeley.edu/people/chaffee/expectnt.html This is an application that controls processes through stdou/stdin. Maybe you can learn from his technique. This file discusses some of the techniques: ftp://bmrc.berkeley.edu/pub/winnt/tcltk/expect/README.NT Can you modify the source code of your child process? If you can modify the code, then you could have it write directly to a file or named pipe instead of stdout. You could also have it write to a database. This is what I ended up doing. None of these ideas helps if you are trying to interface with a precompiled EXE or any application that you cannot modify. I would be very interested to find out if you ever solve this problem. Yours, Noah -----Original Message----- From: python-win32-admin@python.org [mailto:python-win32-admin@python.org]On Behalf Of Moray B. Grieve Sent: Thursday, March 14, 2002 6:56 AM To: python-win32@python.org Subject: [python-win32] win32 equivalent for "my.exe > stdout.txt &" I want to launch a child process from within a python script which will run in the background with all stdout redirected to a file i.e. a unix equivalent of "my.exe > stdout.txt &". To do this I have been trying something like: startupInfo = win32process.STARTUPINFO() startupInfo.hStdInput = win32api.GetStdHandle(STD_INPUT_HANDLE); startupInfo.hStdError = win32api.GetStdHandle(STD_ERR_HANDLE); startupInfo.hStdOutput = win32file.CreateFile("stdout.txt", win32con.GENERIC_WRITE, 0, None, win32con.CREATE_ALWAYS, win32con.FILE_FLAG_WRITE_THROUGH, 0 ) startupInfo.dwFlags = win32con.STARTF_USESTDHANDLES hProcess, hThread, dwPid, dwTid = win32process.CreateProcess( None, # appName "my.exe", # commandLine None, # processAttributes None, # threadAttributes 1, # bInheritHandles 0, # dwCreationFlags None, # newEnvironment None, # currentDirectory startupInfo # startupInfo ) I was hoping that by setting startupInfo.hStdOutput to the newly created file handle, writes to stdout by the child process would automatically be written to file - however this does not seem to tbe the case. Although stdout does get redirected somewhere, it does not go to the file and even flushing the handle does not seem to solve the problem. Am I being to naive in this approach? I have tried all different flags for the win32file.CreateFile and win32process.CreateProcess methods. Do I need to set up the child stdout to a pipe, and manage the read end of the pipe in a thread? I'm a novice in this area so would appreciate any help. Thanks, Moray Grieve From David Rock Tue Mar 19 05:10:49 2002 From: David Rock (David Rock) Date: Mon, 18 Mar 2002 23:10:49 -0600 Subject: [python-win32] Pythonservice.exe running at 100% Message-ID: <20020318231049.B5724@rock.homelinux.com> Every time I try to run a service on Windows NT4, it always runs at 100% CPU utilization. Why does pythonservice.exe do this and is there any way that I can throttle it back? I have managed to minimize the amount of time that the service app I am running takes, so that it is not a tremendous strain on the system (just a couple seconds) but I would like to manage this better. Thanks. -- David Rock david@rock.homelinux.com From mhammond@skippinet.com.au Tue Mar 19 06:13:30 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 19 Mar 2002 17:13:30 +1100 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: <20020318231049.B5724@rock.homelinux.com> Message-ID: > Every time I try to run a service on Windows NT4, it always runs at 100% > CPU utilization. Why does pythonservice.exe do this and is there any way > that I can throttle it back? I have managed to minimize the amount of > time that the service app I am running takes, so that it is not a > tremendous strain on the system (just a couple seconds) but I would like > to manage this better. Something is almost certainly wrong with your service. The test services do not exhibit this. Check that your loops that are supposed to be waiting for something actually are :) Mark. From mhammond@skippinet.com.au Tue Mar 19 06:15:33 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 19 Mar 2002 17:15:33 +1100 Subject: [python-win32] win32 equivalent for "my.exe > stdout.txt &" In-Reply-To: <7CD4BE0203A91845A17CE0E8BD9A128930F5ED@UKCAMMS002.msapama.apama.com> Message-ID: > I want to launch a child process from within a python script which will > run in the background with all stdout redirected to a file i.e. a > unix equivalent of "my.exe > stdout.txt &". To do this I have been > trying something like: I'm not too sure how this differs from using popen from inside a thread? I assume that for some reason you need the process handle? If so, just examine the Python popen implementations, and port them to Python. There are some intricate details you must get correct. Mark. From David Rock Tue Mar 19 16:45:50 2002 From: David Rock (David Rock) Date: Tue, 19 Mar 2002 10:45:50 -0600 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: ; from mhammond@skippinet.com.au on Tue, Mar 19, 2002 at 05:13:30PM +1100 References: <20020318231049.B5724@rock.homelinux.com> Message-ID: <20020319104550.A7132@rock.homelinux.com> On Tue, Mar 19, 2002 at 05:13:30PM +1100, Mark Hammond wrote: > > Every time I try to run a service on Windows NT4, it always runs at 100% > > CPU utilization. Why does pythonservice.exe do this and is there any way > > that I can throttle it back? I have managed to minimize the amount of > > time that the service app I am running takes, so that it is not a > > tremendous strain on the system (just a couple seconds) but I would like > > to manage this better. > > Something is almost certainly wrong with your service. The test services do > not exhibit this. Check that your loops that are supposed to be waiting for > something actually are :) Here is the core of my SvcDoRun: timeout = 120000 waitHandle = self.hWaitStop while 1: rc = win32event.WaitForSingleObject( waitHandle, timeout ) if rc == win32event.WAIT_OBJECT_0: #stop event break else: start_time = time.time() self.run_test(loop) end_time = time.time() diff_time = end_time - start_time self.send_results( start_time, end_time, diff_time, string.lower(t_server), c_server, ftpuser, ftppass, patrol ) While it is waiting for the self.hWaitStop there is no activity, which is what I expect. When the timeout hits and runs the else statement, this is where I have problems. What I do is run a test loop to measure the amount of time it takes for a system to do some basic I/O operations and then it ftps those results to a collection server. Here are the two modules I am using for this: def run_test(self, loop): # Create tempfile to write data to tmp = tempfile.mktemp('.tmp') fp = open( tmp, 'w' ) for x in xrange(1,loop): print >>fp, 'This is a file write test:' print >>fp, '%s' % ( os.listdir( os.environ['systemdrive'] ) ) fp.seek(0) fp.truncate() fp.close() os.remove( tmp ) def send_results(self,stime,etime,dtime,tserver,cserver, ftpuser,ftppass,patrol): if dtime > 3: err = 'ERROR' else: err = '' if patrol == 'no': tmp = tempfile.mktemp('.tmp') fp = open( tmp, 'w' ) tmpdate = time.asctime(time.localtime(stime)) print >>fp, '%s,%s,%f,%s' % ( tserver, tmpdate, dtime, err ) fp.close() # ftp to logging server and append to a log file. ftpcmd = 'APPE pyperf/' + tserver + '.log' fp = open( tmp, 'r' ) ftp = ftplib.FTP( cserver ) ftp.login( ftpuser, ftppass ) ftp.storlines( ftpcmd, fp ) ftp.quit() fp.close() os.remove( tmp ) print '%d' % ( dtime ) Somewhere within one of these two modules is where it pegs the system at 100%. I am pretty new to using Python for writing a service or any Windows event driven programs for that matter, so I have no idea if there is a better way to do this or not. You mentioned that I should be making sure that the loop is actually waiting for something. The only loop that waits for anything is the main loop that waits for the stop service event. Everything else is running after that point. Is there anything I can do within the other modules to get it under control? Thanks. -- David Rock david@rock.homelinux.com From Jim.Vickroy@noaa.gov Tue Mar 19 18:10:36 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Tue, 19 Mar 2002 11:10:36 -0700 Subject: [python-win32] Pythonservice.exe running at 100% References: <20020318231049.B5724@rock.homelinux.com> <20020319104550.A7132@rock.homelinux.com> Message-ID: <3C977F1C.FF69F101@noaa.gov> David, have you tried running your application as a process (not a MS Windows Service)? Specifically, have you "unit tested" the "run_test" and "send_results" methods to see if they exhibit the same behavior in isolation? I have many (more than 10) MS Windows Services (implemented in Python) running in parallel and have never observed this behavior either. David Rock wrote: > On Tue, Mar 19, 2002 at 05:13:30PM +1100, Mark Hammond wrote: > > > Every time I try to run a service on Windows NT4, it always runs at 100% > > > CPU utilization. Why does pythonservice.exe do this and is there any way > > > that I can throttle it back? I have managed to minimize the amount of > > > time that the service app I am running takes, so that it is not a > > > tremendous strain on the system (just a couple seconds) but I would like > > > to manage this better. > > > > Something is almost certainly wrong with your service. The test services do > > not exhibit this. Check that your loops that are supposed to be waiting for > > something actually are :) > > Here is the core of my SvcDoRun: > > timeout = 120000 > waitHandle = self.hWaitStop > > while 1: > rc = win32event.WaitForSingleObject( waitHandle, timeout ) > if rc == win32event.WAIT_OBJECT_0: > #stop event > break > else: > start_time = time.time() > self.run_test(loop) > end_time = time.time() > diff_time = end_time - start_time > self.send_results( start_time, end_time, diff_time, > string.lower(t_server), c_server, > ftpuser, ftppass, patrol ) > > While it is waiting for the self.hWaitStop there is no activity, which > is what I expect. When the timeout hits and runs the else statement, > this is where I have problems. What I do is run a test loop to measure > the amount of time it takes for a system to do some basic I/O operations > and then it ftps those results to a collection server. Here are the two > modules I am using for this: > > def run_test(self, loop): > > # Create tempfile to write data to > tmp = tempfile.mktemp('.tmp') > fp = open( tmp, 'w' ) > > for x in xrange(1,loop): > print >>fp, 'This is a file write test:' > print >>fp, '%s' % ( os.listdir( os.environ['systemdrive'] ) ) > fp.seek(0) > fp.truncate() > > fp.close() > os.remove( tmp ) > > def send_results(self,stime,etime,dtime,tserver,cserver, > ftpuser,ftppass,patrol): > if dtime > 3: > err = 'ERROR' > else: > err = '' > > if patrol == 'no': > tmp = tempfile.mktemp('.tmp') > fp = open( tmp, 'w' ) > tmpdate = time.asctime(time.localtime(stime)) > print >>fp, '%s,%s,%f,%s' % ( tserver, tmpdate, dtime, err ) > fp.close() > > # ftp to logging server and append to a log file. > ftpcmd = 'APPE pyperf/' + tserver + '.log' > fp = open( tmp, 'r' ) > ftp = ftplib.FTP( cserver ) > ftp.login( ftpuser, ftppass ) > ftp.storlines( ftpcmd, fp ) > ftp.quit() > fp.close() > os.remove( tmp ) > > print '%d' % ( dtime ) > > Somewhere within one of these two modules is where it pegs the system at > 100%. I am pretty new to using Python for writing a service or any > Windows event driven programs for that matter, so I have no idea if > there is a better way to do this or not. > > You mentioned that I should be making sure that the loop is actually > waiting for something. The only loop that waits for anything is the > main loop that waits for the stop service event. Everything else is > running after that point. Is there anything I can do within the other > modules to get it under control? > > Thanks. > > -- > David Rock > david@rock.homelinux.com > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From David Rock Tue Mar 19 19:52:53 2002 From: David Rock (David Rock) Date: Tue, 19 Mar 2002 13:52:53 -0600 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: <3C977F1C.FF69F101@noaa.gov>; from Jim.Vickroy@noaa.gov on Tue, Mar 19, 2002 at 11:10:36AM -0700 References: <20020318231049.B5724@rock.homelinux.com> <20020319104550.A7132@rock.homelinux.com> <3C977F1C.FF69F101@noaa.gov> Message-ID: <20020319135253.A7195@rock.homelinux.com> On Tue, Mar 19, 2002 at 11:10:36AM -0700, Jim Vickroy wrote: > David, have you tried running your application as a process (not a MS Windows > Service)? Specifically, have you "unit tested" the "run_test" and "send_results" > methods to see if they exhibit the same behavior in isolation? > > I have many (more than 10) MS Windows Services (implemented in Python) running in > parallel and have never observed this behavior either. > I have a standalone version of the script that does the same thing. It seems to be the run_test module that is in question. This module creates a temp file and rewrites data to the file loop number of times. If I use the script version of it, loop=1000 takes about 1 second to complete If I use the service version of it loop=25 takes about 1 second. In either case, if the loop value is large enough (to see it in the task manager), the process still pegs the cpu at 100% when it is running. So to answer your question, running it standalone has the same cpu problem as running it as a service does. However, this brings up another question of why running as a service is so much slower than running it standalone? Thanks. -- David Rock david@rock.homelinux.com From David Rock Tue Mar 19 21:00:24 2002 From: David Rock (David Rock) Date: Tue, 19 Mar 2002 15:00:24 -0600 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: ; from mhammond@skippinet.com.au on Tue, Mar 19, 2002 at 05:13:30PM +1100 References: <20020318231049.B5724@rock.homelinux.com> Message-ID: <20020319150024.A7548@rock.homelinux.com> On Tue, Mar 19, 2002 at 05:13:30PM +1100, Mark Hammond wrote: > > Every time I try to run a service on Windows NT4, it always runs at 100% > > CPU utilization. Why does pythonservice.exe do this and is there any way > > that I can throttle it back? I have managed to minimize the amount of > > time that the service app I am running takes, so that it is not a > > tremendous strain on the system (just a couple seconds) but I would like > > to manage this better. > > Something is almost certainly wrong with your service. The test services do > not exhibit this. Check that your loops that are supposed to be waiting for > something actually are :) Is there any chance that the version of Python and the WIn32 extensions will be a factor in this? I am currently using Python 2.1.1 from Python.org with Win32all-145. I am in the process of downloading 2.2 and win32all-146 to see if it makes a difference. -- David Rock david@rock.homelinux.com From David Rock Tue Mar 19 22:12:13 2002 From: David Rock (David Rock) Date: Tue, 19 Mar 2002 16:12:13 -0600 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: <20020319150024.A7548@rock.homelinux.com>; from david@rock.homelinux.com on Tue, Mar 19, 2002 at 03:00:24PM -0600 References: <20020318231049.B5724@rock.homelinux.com> <20020319150024.A7548@rock.homelinux.com> Message-ID: <20020319161213.A7651@rock.homelinux.com> On Tue, Mar 19, 2002 at 03:00:24PM -0600, David Rock wrote: > On Tue, Mar 19, 2002 at 05:13:30PM +1100, Mark Hammond wrote: > > > Every time I try to run a service on Windows NT4, it always runs at 100% > > > CPU utilization. Why does pythonservice.exe do this and is there any way > > > that I can throttle it back? I have managed to minimize the amount of > > > time that the service app I am running takes, so that it is not a > > > tremendous strain on the system (just a couple seconds) but I would like > > > to manage this better. > > > > Something is almost certainly wrong with your service. The test services do > > not exhibit this. Check that your loops that are supposed to be waiting for > > something actually are :) > > Is there any chance that the version of Python and the WIn32 extensions > will be a factor in this? I am currently using Python 2.1.1 from > Python.org with Win32all-145. > > I am in the process of downloading 2.2 and win32all-146 to see if it > makes a difference. I have tried this with Python 2.2 and Win32all-146 and I get the same thing. The cpu pegs at 100% whenever it is running. I suppose this is just because the service isn't really designed well as an event-driven app, since the whole point of it is to see what happens when you run I/O constantly X number of times. I would still like to know why there is such a drastic difference between the standalone's speed and the service's speed (loops=1000 and loops=25 respectively). Oh well. I guess I'll just make sure I test it out before using it in production ;-) BTW, thanks for the development Mark. This will prove invaluable for what I am doing at work. -- David Rock david@rock.homelinux.com From mhammond@skippinet.com.au Wed Mar 20 00:08:02 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Wed, 20 Mar 2002 11:08:02 +1100 Subject: [python-win32] Pythonservice.exe running at 100% Message-ID: [David] > I have a standalone version of the script that does the same thing. It > seems to be the run_test module that is in question. This module creates > a temp file and rewrites data to the file loop number of times. If I use > the script version of it, loop=1000 takes about 1 second to complete If > I use the service version of it loop=25 takes about 1 second. In either > case, if the loop value is large enough (to see it in the task manager), > the process still pegs the cpu at 100% when it is running. I guess there are 2 possibilities: * Something else is also hogging the CPU. * There is issue when running under the service account. If you debug your service (ie, yourservice.py --debug) do you see the same behaviour? Mark. From David Rock Wed Mar 20 05:03:48 2002 From: David Rock (David Rock) Date: Tue, 19 Mar 2002 23:03:48 -0600 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: ; from mhammond@skippinet.com.au on Wed, Mar 20, 2002 at 11:08:02AM +1100 References: Message-ID: <20020319230348.A8489@rock.homelinux.com> On Wed, Mar 20, 2002 at 11:08:02AM +1100, Mark Hammond wrote: > [David] > > I have a standalone version of the script that does the same thing. It > > seems to be the run_test module that is in question. This module creates > > a temp file and rewrites data to the file loop number of times. If I use > > the script version of it, loop=1000 takes about 1 second to complete If > > I use the service version of it loop=25 takes about 1 second. In either > > case, if the loop value is large enough (to see it in the task manager), > > the process still pegs the cpu at 100% when it is running. > > I guess there are 2 possibilities: > * Something else is also hogging the CPU. > * There is issue when running under the service account. > > If you debug your service (ie, yourservice.py --debug) do you see the same > behaviour? When I debug the service, it behaves like the standalone app does; actually, it behaves better. The system resources spike to 100% but don't stay there, and the number of loops per second is similar to the standalone version. So what does this mean? I don't see any indication that anything is hogging the CPU while in debug mode. Should I create a test account to try running the service under to see if that makes a difference? I did notice that python.exe is running while in debug mode as well as pythonservice.exe. I assume this is because it's actually calling the console version of python? -- David Rock david@rock.homelinux.com From andrew-pywin32@puzzling.org Wed Mar 20 05:46:22 2002 From: andrew-pywin32@puzzling.org (Andrew Bennetts) Date: Wed, 20 Mar 2002 16:46:22 +1100 Subject: [python-win32] Pythonservice.exe running at 100% In-Reply-To: <20020319230348.A8489@rock.homelinux.com> References: <20020319230348.A8489@rock.homelinux.com> Message-ID: <20020320054622.GA24737@ritsuko.xware.cx> On Tue, Mar 19, 2002 at 11:03:48PM -0600, David Rock wrote: > So what does this mean? I don't see any indication that anything is > hogging the CPU while in debug mode. Should I create a test account to > try running the service under to see if that makes a difference? I think so, yes. Run the standalone under the same test account as well, of course... -Andrew. From MarkA@sundance.com Wed Mar 20 10:26:52 2002 From: MarkA@sundance.com (Mark Ainsworth) Date: Wed, 20 Mar 2002 10:26:52 -0000 Subject: [python-win32] generating data plots. Message-ID: Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. Thanks. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com begin 600 winmail.dat M>)\^(CL*`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<` M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T@<#`!0` M"@`:`#0``P!+`0$@@`,`#@```-('`P`4``H`&@`Y``,`4`$!"8`!`"$````R M,S%"-$(R,3(R,T)$-C$Q.#%"-3`P03`R-$4W130W-0#>!@$$@`$`%P```&=E M;F5R871I;F<@9&%T82!P;&]T`""`&``````#`````````1@`````1A0````````,` M"(`((`8``````,````````!&`````!B%`````````@$)$`$```"\"```N`@` M`)$5``!,6D9U#E;T00,`"@!R8W!G,3(U5*$_U2B4P]6WU:=5A]43U*?$&#\,CA<:EV!73]>25*$7G*_7-]@KV!M M7^]>'V'D.0Y0'V4T9I%>LV:0`H)S='E>;`>0'D`;4```<0,A;!YI`4`%$`%` M`_!D8W3V;`JQ`&!S"K!IT!L0:A((;G5M`@!A875T8F\`8&1J=6@`!1!GO&AT M:3$*`6D`"@%I`9!\<#`#,4WB#`$/4@'0-3]*T!`8"-`)P&F0;=-N<`]N*6_` M#Y(#,'-N97@_&V`'L`6P`,`"!$8?AT93ITE"Q@=1]V+W<__WA/ M>5]Z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%?GB6\(>1`1I`X47=1$6C/+28\$CRO/;U1=>+0,N#N>;PA MO\`?('(_B$!//;V_@D#0L"@@U!!0('-Q:9Y!W]003D#7\+`@@H!HX('F,.U" MH$SIX"H&0R9P2B"B@-T2\$B7P,!P)9@) M/Z]O``!``#D`\""#P/G/P0$#`/$_"00``!X`,4`!````!P```$U!4DM!,0`` M`P`:0``````>`#!``0````<```!-05)+03$```,`&4```````P#]/^0$```# M`(`0_____P(!1P`!````-@```&,]1T([83T@.W`]4W5N9&%N8V4@375L=&EP M Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. Thanks. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com begin 600 winmail.dat M>)\^(CL*`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<` M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T@<#`!0` M"@`:`#0``P!+`0$@@`,`#@```-('`P`4``H`&@`Y``,`4`$!"8`!`"$````R M,S%"-$(R,3(R,T)$-C$Q.#%"-3`P03`R-$4W130W-0#>!@$$@`$`%P```&=E M;F5R871I;F<@9&%T82!P;&]T`""`&``````#`````````1@`````1A0````````,` M"(`((`8``````,````````!&`````!B%`````````@$)$`$```"\"```N`@` M`)$5``!,6D9U#E;T00,`"@!R8W!G,3(U5*$_U2B4P]6WU:=5A]43U*?$&#\,CA<:EV!73]>25*$7G*_7-]@KV!M M7^]>'V'D.0Y0'V4T9I%>LV:0`H)S='E>;`>0'D`;4```<0,A;!YI`4`%$`%` M`_!D8W3V;`JQ`&!S"K!IT!L0:A((;G5M`@!A875T8F\`8&1J=6@`!1!GO&AT M:3$*`6D`"@%I`9!\<#`#,4WB#`$/4@'0-3]*T!`8"-`)P&F0;=-N<`]N*6_` M#Y(#,'-N97@_&V`'L`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MN(B+@/N(W0#U`_W.!=+"; MX9Q`G:&<`9R/0>%?GB6\(>1`1I`X47=1$6C/+28\$CRO/;U1=>+0,N#N>;PA MO\`?('(_B$!//;V_@D#0L"@@U!!0('-Q:9Y!W]003D#7\+`@@H!HX('F,.U" MH$SIX"H&0R9P2B"B@-T2\$B7P,!P)9@) M/Z]O``!``#D`\""#P/G/P0$#`/$_"00``!X`,4`!````!P```$U!4DM!,0`` M`P`:0``````>`#!``0````<```!-05)+03$```,`&4```````P#]/^0$```# M`(`0_____P(!1P`!````-@```&,]1T([83T@.W`]4W5N9&%N8V4@375L=&EP M Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. Thanks. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com begin 600 winmail.dat M>)\^(CL*`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<` M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T@<#`!0` M"@`:`#0``P!+`0$@@`,`#@```-('`P`4``H`&@`Y``,`4`$!"8`!`"$````R M,S%"-$(R,3(R,T)$-C$Q.#%"-3`P03`R-$4W130W-0#>!@$$@`$`%P```&=E M;F5R871I;F<@9&%T82!P;&]T`""`&``````#`````````1@`````1A0````````,` M"(`((`8``````,````````!&`````!B%`````````@$)$`$```"\"```N`@` M`)$5``!,6D9U#E;T00,`"@!R8W!G,3(U5*$_U2B4P]6WU:=5A]43U*?$&#\,CA<:EV!73]>25*$7G*_7-]@KV!M M7^]>'V'D.0Y0'V4T9I%>LV:0`H)S='E>;`>0'D`;4```<0,A;!YI`4`%$`%` M`_!D8W3V;`JQ`&!S"K!IT!L0:A((;G5M`@!A875T8F\`8&1J=6@`!1!GO&AT M:3$*`6D`"@%I`9!\<#`#,4WB#`$/4@'0-3]*T!`8"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<;60 M:``'&U*^84:0551/5$7`6%1,25-4+M!TP/0@(LMN(B+@/N(W0#U`_W.!=+"; MX9Q`G:&<`9R/0>%?GB6\(>1`1I`X47=1$6C/+28\$CRO/;U1=>+0,N#N>;PA MO\`?('(_B$!//;V_@D#0L"@@U!!0('-Q:9Y!W]003D#7\+`@@H!HX('F,.U" MH$SIX"H&0R9P2B"B@-T2\$B7P,!P)9@) M/Z]O``!``#D`\""#P/G/P0$#`/$_"00``!X`,4`!````!P```$U!4DM!,0`` M`P`:0``````>`#!``0````<```!-05)+03$```,`&4```````P#]/^0$```# M`(`0_____P(!1P`!````-@```&,]1T([83T@.W`]4W5N9&%N8V4@375L=&EP M Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. Thanks. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com begin 600 winmail.dat M>)\^(CL*`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<` M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T@<#`!0` M"@`:`#0``P!+`0$@@`,`#@```-('`P`4``H`&@`Y``,`4`$!"8`!`"$````R M,S%"-$(R,3(R,T)$-C$Q.#%"-3`P03`R-$4W130W-0#>!@$$@`$`%P```&=E M;F5R871I;F<@9&%T82!P;&]T`""`&``````#`````````1@`````1A0````````,` M"(`((`8``````,````````!&`````!B%`````````@$)$`$```"\"```N`@` M`)$5``!,6D9U#E;T00,`"@!R8W!G,3(U5*$_U2B4P]6WU:=5A]43U*?$&#\,CA<:EV!73]>25*$7G*_7-]@KV!M M7^]>'V'D.0Y0'V4T9I%>LV:0`H)S='E>;`>0'D`;4```<0,A;!YI`4`%$`%` M`_!D8W3V;`JQ`&!S"K!IT!L0:A((;G5M`@!A875T8F\`8&1J=6@`!1!GO&AT M:3$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__%G\7CQB?&:\:NZ-PF"`U4/YF-T!1D#+@[0(W<;60 M:``'&U*^84:0551/5$7`6%1,25-4+M!TP/0@(LMN(B+@/N(W0#U`_W.!=+"; MX9Q`G:&<`9R/0>%?GB6\(>1`1I`X47=1$6C/+28\$CRO/;U1=>+0,N#N>;PA MO\`?('(_B$!//;V_@D#0L"@@U!!0('-Q:9Y!W]003D#7\+`@@H!HX('F,.U" MH$SIX"H&0R9P2B"B@-T2\$B7P,!P)9@) M/Z]O``!``#D`\""#P/G/P0$#`/$_"00``!X`,4`!````!P```$U!4DM!,0`` M`P`:0``````>`#!``0````<```!-05)+03$```,`&4```````P#]/^0$```# M`(`0_____P(!1P`!````-@```&,]1T([83T@.W`]4W5N9&%N8V4@375L=&EP M Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. Thanks. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com begin 600 winmail.dat M>)\^(CL*`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<` M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T@<#`!0` M"@`:`#0``P!+`0$@@`,`#@```-('`P`4``H`&@`Y``,`4`$!"8`!`"$````R M,S%"-$(R,3(R,T)$-C$Q.#%"-3`P03`R-$4W130W-0#>!@$$@`$`%P```&=E M;F5R871I;F<@9&%T82!P;&]T`""`&``````#`````````1@`````1A0````````,` M"(`((`8``````,````````!&`````!B%`````````@$)$`$```"\"```N`@` M`)$5``!,6D9U#E;T00,`"@!R8W!G,3(U5*$_U2B4P]6WU:=5A]43U*?$&#\,CA<:EV!73]>25*$7G*_7-]@KV!M M7^]>'V'D.0Y0'V4T9I%>LV:0`H)S='E>;`>0'D`;4```<0,A;!YI`4`%$`%` M`_!D8W3V;`JQ`&!S"K!IT!L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2RB`J%53W06MS\)`C#^^^ M82H<$DS!HV,33Q1?%6__%G\7CQB?&:\:NZ-PF"`U4/YF-T!1D#+@[0(W<;60 M:``'&U*^84:0551/5$7`6%1,25-4+M!TP/0@(LMN(B+@/N(W0#U`_W.!=+"; MX9Q`G:&<`9R/0>%?GB6\(>1`1I`X47=1$6C/+28\$CRO/;U1=>+0,N#N>;PA MO\`?('(_B$!//;V_@D#0L"@@U!!0('-Q:9Y!W]003D#7\+`@@H!HX('F,.U" MH$SIX"H&0R9P2B"B@-T2\$B7P,!P)9@) M/Z]O``!``#D`\""#P/G/P0$#`/$_"00``!X`,4`!````!P```$U!4DM!,0`` M`P`:0``````>`#!``0````<```!-05)+03$```,`&4```````P#]/^0$```# M`(`0_____P(!1P`!````-@```&,]1T([83T@.W`]4W5N9&%N8V4@375L=&EP M Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. Thanks. Mark Ainsworth Quality Manager Sundance Multiprocessor Technology Ltd. Chiltern House, Waterside, Chesham, Bucks HP5 1PS Tel. +44 1494 793167 Fax. +44 1494 793168 MarkA@sundance.com http://www.sundance.com begin 600 winmail.dat M>)\^(CL*`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<` M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T@<#`!0` M"@`:`#0``P!+`0$@@`,`#@```-('`P`4``H`&@`Y``,`4`$!"8`!`"$````R M,S%"-$(R,3(R,T)$-C$Q.#%"-3`P03`R-$4W130W-0#>!@$$@`$`%P```&=E M;F5R871I;F<@9&%T82!P;&]T`""`&``````#`````````1@`````1A0````````,` M"(`((`8``````,````````!&`````!B%`````````@$)$`$```"\"```N`@` M`)$5``!,6D9U#E;T00,`"@!R8W!G,3(U5*$_U2B4P]6WU:=5A]43U*?$&#\,CA<:EV!73]>25*$7G*_7-]@KV!M M7^]>'V'D.0Y0'V4T9I%>LV:0`H)S='E>;`>0'D`;4```<0,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-KA\QX"*Z!S87,!%U`H\!S!B7.@1$8D\RX-"A)2RB`J%53W06MS\)`C#^^^ M82H<$DS!HV,33Q1?%6__%G\7CQB?&:\:NZ-PF"`U4/YF-T!1D#+@[0(W<;60 M:``'&U*^84:0551/5$7`6%1,25-4+M!TP/0@(LMN(B+@/N(W0#U`_W.!=+"; MX9Q`G:&<`9R/0>%?GB6\(>1`1I`X47=1$6C/+28\$CRO/;U1=>+0,N#N>;PA MO\`?('(_B$!//;V_@D#0L"@@U!!0('-Q:9Y!W]003D#7\+`@@H!HX('F,.U" MH$SIX"H&0R9P2B"B@-T2\$B7P,!P)9@) M/Z]O``!``#D`\""#P/G/P0$#`/$_"00``!X`,4`!````!P```$U!4DM!,0`` M`P`:0``````>`#!``0````<```!-05)+03$```,`&4```````P#]/^0$```# M`(`0_____P(!1P`!````-@```&,]1T([83T@.W`]4W5N9&%N8V4@375L=&EP M Message-ID: <3C98A39F.3000503@tallan.com> This is a multi-part message in MIME format. --------------010307070106070508040508 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit My advice would be to use the PSDraw module (part of PIL) to output postscript and then convert that to pdf with ghostscript. I used the pay version of Acrobat for the conversion so if you've got that or want to lay out the $ then that's a good option. You might want to get a book on postscript, it is actually a pretty high-level drawing language. The PSDraw module though simplifies things a little bit. Attached is a script I used to get information from a SQL Server database trace about when locks were happening so I could see the contention between threads. I generated a massive graph which spanned like 30 pages which I taped together and put up on the wall. In the end the graph didn't help us that much but it was cool to build and worked great. Mark Ainsworth wrote: >Can anyone point me to the right site/pages to read to figure out what >packages I need to be able to read a text file of data, convert this to >a simple line graph and then save it in a PDF file. > >Thanks. > >Mark Ainsworth >Quality Manager >Sundance Multiprocessor Technology Ltd. >Chiltern House, Waterside, Chesham, Bucks HP5 1PS >Tel. +44 1494 793167 Fax. +44 1494 793168 >MarkA@sundance.com http://www.sundance.com > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com --------------010307070106070508040508 Content-Type: text/plain; name="big_graph.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="big_graph.py" from win32com.client import Dispatch import ADO, sys, time, os, re sys.path.append('c:\\py21\\DLLs') sys.path.append('c:\\py21\\PIL') import PSDraw # draw the time lines margin = 0.25 # leave a quarter inch margin all around page_cols = 5 # five time lines per page vert_pages = 4 # four pages long on the lines tl_width = (8.5 - margin * 2) / page_cols def inch2pts(v) : return v * 72 def draw_lines(ps) : start_y = 11 - margin end_y = margin x = margin for i in xrange(0, page_cols) : ps.line((inch2pts((margin) + i * tl_width), inch2pts(start_y)), (inch2pts((margin) + i * tl_width), inch2pts(end_y))) class EventClass : SQL_StmtStarting = 40 SQL_StmtCompleted = 41 Lock_Timeout = 27 Object_Opened = 48 Object_Closed = 49 cn = ADO.Connection() cn.Provider = 'sqloledb' cn.Open('Server=XXXXXX', 'sa', 'XXXXX') # get the object names for Object_Opens so we can map them when we have a # LockTimeout (rs, rows) = cn.Execute("select ObjectID, TextData from c2ctrace where EventClass = 48 and EventSubClass = 8277") object_ids = {} while not rs.EOF : object_ids[rs.Fields.Item(0).Value] = rs.Fields.Item(1).Value rs.MoveNext() def get_objectid(id) : try : return object_ids[id] except : return '' # based on the number of pages we're drawing over we need to determine what # time quantity will go on each page. so, we need to select the min and max # values of the time (rs, rows) = cn.Execute("select min(StartTime), max(StartTime) from c2ctrace where EventClass = 40 or EventClass = 27 and SPID is not NULL") min_time = float(rs.Fields.Item(0).Value) max_time = float(rs.Fields.Item(1).Value) rs.Close() # we adjust the min_time and max_time so that we get 0.5 inch of space at the top # and bottom of the timelines buffer_time = 0.5 * (max_time - min_time) / (vert_pages * (11 - 2 * margin)) min_time -= buffer_time max_time += buffer_time time_per_page = (max_time - min_time) / vert_pages # first get the unique SPIDS (rs, rows) = cn.Execute("select distinct(SPID) from c2ctrace") spids = [] while not rs.EOF : if rs.Fields.Item(0).Value != None : spids.append(rs.Fields.Item(0).Value) rs.MoveNext() rs.Close() # now that we know how many SPIDs there are we can set up the PSDraw instances. # we do each page individually so it's easier for us to do with the SQL as it's # coming back. the variable pages is a list of lists of PSDraw instances. Once # it is created thus we can access it like pages[1][2] pages = [] for i in xrange(0, (len(spids) + (page_cols-1)) / page_cols) : col = [] for j in xrange(0, vert_pages) : ps = PSDraw.PSDraw(open('c:\\temp\\trace_%d-%d.ps' % (i+1,j+1), 'wb')) ps.begin_document() # draw the time-lines ps.setfont('Times-Roman', 12) draw_lines(ps) # draw the page coordinates in the lower-right corner ps.text((inch2pts(8.5-margin-0.25), inch2pts(margin)), '(%d, %d)' % (i+1,j+1)) col.append(ps) pages.append(col) # now the output pages are initialized we can go through and get our data # and render it onto the pages for i in xrange(0, len(spids)) : (rs, rows) = cn.Execute("select StartTime, TextData, EventClass, ObjectID from c2ctrace where (EventClass = 40 or EventClass = 27) and SPID = %s order by StartTime" % spids[i]) # we can figure out here which column of pages and which column on that page # we're dealing with page_col = pages[i / page_cols] col = i % page_cols # while we're at it we can get the base x value where the timeline is # drawn x_ref = margin + col * tl_width # write our spid at the top of the timeline page_col[0].text((inch2pts(x_ref+0.1), inch2pts(11 - margin) - 12), "SPID %s" % spids[i]) while not rs.EOF : s = rs.Fields.Item(1).Value if s == 'IF @@TRANCOUNT > 0' : rs.MoveNext() continue # we need to take the start time and figure out from it what page row # we're on timestamp = float(rs.Fields.Item(0).Value) timestamp -= min_time # adjust for the origin of our time secs = timestamp page_row = int(timestamp / time_per_page) if page_row >= len(page_col) : page_row = len(page_col) - 1 # now adjust the timestamp value for intra-page placement timestamp -= page_row * time_per_page y_ref = (11 - 2 * margin) * (1.0 - timestamp / time_per_page) + margin # draw a short horizontal line to mark this spot page_col[page_row].line((inch2pts(x_ref), inch2pts(y_ref)), (inch2pts(x_ref+0.125), inch2pts(y_ref))) # write the timestamp, and following lines lines = [] lines.append('%0.3f' % (secs * 24 * 60 * 60)) if rs.Fields.Item(2).Value == '40' : s = rs.Fields.Item(1).Value s = s[0:40] # just the first (no more than) 40 chars #print repr(s) lines.extend(re.split('[\\r\\n]+', s)) #f.write("%s %s\n" % (time.ctime(int(rs.Fields.Item(0).Value)), )) elif rs.Fields.Item(2).Value == '27' : lines.append("LockTimeout:") lines.append(str(get_objectid(rs.Fields.Item(3).Value))) #f.write("%s LockTimeout\n" % time.ctime(int(rs.Fields.Item(0).Value))) x = x_ref + 0.1 y = y_ref + 2.0/72.0 # just to get it above the horizontal line for l in lines : page_col[page_row].text((inch2pts(x), inch2pts(y)), l) y -= 12.0 / 72.0 rs.MoveNext() # now go through all the pages and finish them up for i in pages : for j in i : j.end_document() # fini! --------------010307070106070508040508-- From noah@sfbags.com Wed Mar 20 20:08:47 2002 From: noah@sfbags.com (Noah Spurrier) Date: Wed, 20 Mar 2002 12:08:47 -0800 Subject: [python-win32] RE: generating data plots. In-Reply-To: Message-ID: There is a free Open Source PDF library called ReportLab here: http://www.reportlab.com/toolkit/index.html PIL (Python Imaging Library) supports PDF Write. I have not used it, but it is in their documentation: http://www.pythonware.com/library/pil/handbook/image-file-formats.htm Then there is Piddle, which is a plot library for Python that supports PDF Generation: http://piddle.sourceforge.net/notesPDF/index.html For a sample, check out "codeplot" on this page: http://starship.python.net/crew/gherman/ It looks pretty simple and straightforward. Good luck. Send me a demo if you get it working. I'm curious to see which method works best for you. Yours, Noah > -----Original Message----- > From: python-win32-admin@python.org [mailto:python-win32-admin@python.org] On Behalf Of Mark Ainsworth > Sent: Wednesday, March 20, 2002 2:27 AM > To: 'python-win32@python.org' > Subject: generating data plots. > > Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. > > Thanks. > > Mark Ainsworth > Quality Manager > Sundance Multiprocessor Technology Ltd. > Chiltern House, Waterside, Chesham, Bucks HP5 1PS > Tel. +44 1494 793167 Fax. +44 1494 793168 > MarkA@sundance.com http://www.sundance.com > << File: ATT00027.txt >> From noah@noah.org Wed Mar 20 18:04:05 2002 From: noah@noah.org (Noah Spurrier) Date: Wed, 20 Mar 2002 10:04:05 -0800 Subject: [python-win32] RE: generating data plots. Message-ID: <005601c1d039$b298b4b0$6501a8c0@fs> PIL (Python Imaging Library) supports PDF Write. I have not used it, but it is in their documentation: http://www.pythonware.com/library/pil/handbook/image-file-formats.htm Then there is Piddle, which is a plot library for Python that supports PDF Generation: http://piddle.sourceforge.net/notesPDF/index.html For a sample, check out "codeplot" on this page: http://starship.python.net/crew/gherman/ It looks pretty simple and straightforward. There is also a free Open Source PDF library called ReportLab here: http://www.reportlab.com/toolkit/index.html Good luck. Send me a demo if you get it working. I'm curious to see which method works best for you. Yours, Noah > -----Original Message----- > From: python-win32-admin@python.org [mailto:python-win32-admin@python.org] On Behalf Of Mark Ainsworth > Sent: Wednesday, March 20, 2002 2:27 AM > To: 'python-win32@python.org' > Subject: generating data plots. > > Can anyone point me to the right site/pages to read to figure out what packages I need to be able to read a text file of data, convert this to a simple line graph and then save it in a PDF file. > > Thanks. > > Mark Ainsworth > Quality Manager > Sundance Multiprocessor Technology Ltd. > Chiltern House, Waterside, Chesham, Bucks HP5 1PS > Tel. +44 1494 793167 Fax. +44 1494 793168 > MarkA@sundance.com http://www.sundance.com > << File: ATT00027.txt >> From thomas.jacobsen@sveg.se.sykes.com Mon Mar 25 08:33:22 2002 From: thomas.jacobsen@sveg.se.sykes.com (Thomas Jacobsen) Date: Mon, 25 Mar 2002 09:33:22 +0100 Subject: [python-win32] Help needed! Problems with VB & PythonWin Message-ID: Hi There, I have a problem with intergrating Python in VB... What i will is to have VB's GUI, and Pythons code for functions, database etc.(this should be dynamic code, i fyou know what i mean?!) Because i have followed the example at www.hps1.demon.co.uk/users/andy/pyvb/ , And i can get it to work etc. But in the example there is no example for like changing a list in the python code, push a 'refresh'-button, and seee the changes in VB without needing the restart the VB application.. Is it possible to make a 'streamin' object in COM ?! So VB get the changes, when they are made, or how should i solve this ?! Any help would be appriciated! /Thomas "Knowledge is of two kinds. We know a subject ourselves, or we know where we can find information on it." -- Samuel Johnson From mrroach@uhg.net Mon Mar 25 00:11:08 2002 From: mrroach@uhg.net (Mark Roach) Date: 24 Mar 2002 18:11:08 -0600 Subject: [python-win32] Huge print spool files Message-ID: <1017015074.15650.28.camel@mrlinux> I am trying to print a large image (a TIFF fax image), and I can't figure out how to make it more efficient. It is spooling almost 100MB for each page. Other image viewers are only spooling ~500K. I am using PIL to scale the image to full page and then using ImageWin.expose on the printer CDC. Anyone know a better way to do this? newImg = myPImg.resize((5100,6600)) myImgW = ImageWin.Dib("RGB", (newImg.size)) myImgW.paste(newImg) myCDC.StartDoc('TestAgain') myCDC.StartPage() myImgW.expose(myCDC.GetHandleAttrib()) myCDC.EndPage() myCDC.EndDoc() From David Rock Mon Mar 25 19:37:39 2002 From: David Rock (David Rock) Date: Mon, 25 Mar 2002 13:37:39 -0600 Subject: [python-win32] Service error in Terminal Server 4.0 Message-ID: <20020325133739.A29336@rock.homelinux.com> I am getting an error while trying to use pythonservice.exe, but it seems to be coming up only in MS TS4.0: 1061 The service cannot accept control messages at this time I get this when I try to stop the service because it appears to have stalled. I have no problems with the service under WINNT4.0 or WIN2000. If I try to kill the process from within the task manager, I get an error that access is denied (it is currently running as the SYSTEM account. Any ideas of what to look for? -- David Rock david@rock.homelinux.com From mhammond@skippinet.com.au Tue Mar 26 00:34:00 2002 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 26 Mar 2002 11:34:00 +1100 Subject: [python-win32] Service error in Terminal Server 4.0 In-Reply-To: <20020325133739.A29336@rock.homelinux.com> Message-ID: This can happen if the service shutdown causes an error. If you are lucky you will see an entry in the event log. If not, you may need to add your own debugging statements to the SvcStop function to try and see where it fails. The "access denied" error is common when a service fails to stop in this way. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of David Rock > Sent: Tuesday, 26 March 2002 6:38 AM > To: python-win32@python.org > Subject: [python-win32] Service error in Terminal Server 4.0 > > > I am getting an error while trying to use pythonservice.exe, but it > seems to be coming up only in MS TS4.0: > > 1061 The service cannot accept control messages at this time > > I get this when I try to stop the service because it appears to have > stalled. I have no problems with the service under WINNT4.0 or WIN2000. > > If I try to kill the process from within the task manager, I get an > error that access is denied (it is currently running as the SYSTEM > account. > > Any ideas of what to look for? > > -- > David Rock > david@rock.homelinux.com > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From Drew.Whitehouse@anu.edu.au Tue Mar 26 09:52:33 2002 From: Drew.Whitehouse@anu.edu.au (Drew Whitehouse) Date: 26 Mar 2002 20:52:33 +1100 Subject: [python-win32] win32 pipes and CreateProcess Message-ID: Hi, I'm investigating some problems I'm having with win32 process creation and in the course of investigating the matter I've noticed this behavior ... If you modify the example in win32/demos/pipes/runproc.py so that the test is if __name__ == '__main__': import time while 1: p = Process() exe = win32api.GetModuleFileName(0) p.run(exe + ' cat.py') time.sleep(1) It crashes with .... $ python runproc.py Read on stdout: 'hmmmmm\r\n' Read on stderr: 'Blah...' Read on stdout: 'hmmmmm\r\n' Read on stderr: 'Blah...' Traceback (most recent call last): File "runproc.py", line 111, in ? time.sleep(1) pywintypes.api_error: (6, 'CloseHandle', 'The handle is invalid.') Any ideas ? -Drew -- ;; Drew.Whitehouse@anu.edu.au Sci-Viz/VR Programmer ;; http://anusf.anu.edu.au/~drw900 ANUSF VIZLAB ;; Australian National University Supercomputer Facility From garber@centralcatholic.org Wed Mar 27 15:36:53 2002 From: garber@centralcatholic.org (Robert Garber) Date: Wed, 27 Mar 2002 10:36:53 -0500 Subject: [python-win32] HELP with py2exe Message-ID: <200203271036.AA596443584@centralcatholic.org> Hello all, Stuck on py2exe. I seem to be having a problem getting this to work. I have followed thte steps that are on the web page, but with no luck. I am wondering if I have things in the right directory (WIN98). ANy ideas out there? The dos's say: run python setup.py py2exe Which run are they talking about I have tried run from winpython, MSDOS, at the >>> in the interprter, with no luck.. thanks, Robert From reggie@merfinllc.com Wed Mar 27 17:38:54 2002 From: reggie@merfinllc.com (Reggie Dugard) Date: 27 Mar 2002 09:38:54 -0800 Subject: [python-win32] HELP with py2exe In-Reply-To: <200203271036.AA596443584@centralcatholic.org> References: <200203271036.AA596443584@centralcatholic.org> Message-ID: <1017250735.2553.4.camel@auk> Assuming you have python.exe in your PATH and the setup.py for py2exe is in your current directory, you should type "python setup.py py2exe" at the DOS prompt. This will cause python to run the setup.py script with py2exe as its argument. On Wed, 2002-03-27 at 07:36, Robert Garber wrote: > Hello all, > > Stuck on py2exe. I seem to be having a problem getting this to work. I have followed thte steps that are on the web page, but with no luck. > > I am wondering if I have things in the right directory (WIN98). ANy ideas out there? > > The dos's say: > run python setup.py py2exe > > Which run are they talking about I have tried run from winpython, MSDOS, at the >>> in the interprter, with no luck.. > > thanks, > Robert > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jeff@ccvcorp.com Wed Mar 27 17:48:02 2002 From: jeff@ccvcorp.com (Jeff Shannon) Date: Wed, 27 Mar 2002 09:48:02 -0800 Subject: [python-win32] HELP with py2exe References: Message-ID: <3CA205D2.9D477C9B@ccvcorp.com> > "Robert Garber" wrote: > > Stuck on py2exe. I seem to be having a problem getting this to work. I have followed thte steps that are on the web page, but with no luck. > > I am wondering if I have things in the right directory (WIN98). ANy ideas out there? > > The dos's say: > run python setup.py py2exe > > Which run are they talking about I have tried run from winpython, MSDOS, at the >>> in the interprter, with no luck.. You do not actually type the word run. This should be done from the MSDOS prompt. You'll first want to cd to the directory that your package is in, like so: C:\> cd \python21\MyPackage C:\Python21\MyPackage> (The C:\> and the second line are the DOS prompt.) Then, you run python with the specified parameters, like so: C:\Python21\MyPackage> python setup.py py2exe Hope this helps... Jeff Shannon Technician/Programmer Credit International From Jim.Vickroy@noaa.gov Thu Mar 28 15:24:44 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Thu, 28 Mar 2002 08:24:44 -0700 Subject: [python-win32] testing multiple versions of modules Message-ID: <3CA335BC.FCD1FCD5@noaa.gov> I wish to conveniently test multiple versions of my Python application modules on a MS Windows platform. I want to avoid manually editing the Windows registry each time I want to modify the Python search path. Is modifying the contents of sys.path the way to do this and is use of the _winreg module API the best way to modify sys.path? Advice would be appreciated. Thanks. From jens.jorgensen@tallan.com Thu Mar 28 15:35:44 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Thu, 28 Mar 2002 09:35:44 -0600 Subject: [python-win32] testing multiple versions of modules References: <3CA335BC.FCD1FCD5@noaa.gov> Message-ID: <3CA33850.9000006@tallan.com> It is convenient to simply set the PYTHONPATH environment variable. The contents of this path are tacked on to the end of the standard sys.path. BTW if you would like to use a registry module that has an easy to use and really-pythonified interface you could also try out my pyRegistry module (http://www.ultraemail.net/~jbj1). Jim Vickroy wrote: >I wish to conveniently test multiple versions of my Python application >modules on a MS Windows platform. I want to avoid manually editing the >Windows registry each time I want to modify the Python search path. Is >modifying the contents of sys.path the way to do this and is use of the >_winreg module API the best way to modify sys.path? > >Advice would be appreciated. Thanks. > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com From Jim.Vickroy@noaa.gov Thu Mar 28 15:46:46 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Thu, 28 Mar 2002 08:46:46 -0700 Subject: [python-win32] testing multiple versions of modules References: <3CA335BC.FCD1FCD5@noaa.gov> <3CA33850.9000006@tallan.com> Message-ID: <3CA33AE6.A70F3B72@noaa.gov> Thanks Jens. I will look at your module. I'm not much of a MS Windows programmer, but on page 27 of "Python Programming on Win32" there is the statement that good Windows applications store their information in the Windows Registry so I thought that was the preferred way. Anyway, at run time, I need to be able to control the order of the entries in sys.path so that older versions of some modules are not imported instead of the newer versions. Im assuming sys.path is searched from first to last to resolve import requests. I guess I need so directory naming convention that readily sorts from "newest" to "oldest" directory path. "Jens B. Jorgensen" wrote: > It is convenient to simply set the PYTHONPATH environment variable. The > contents of this path are tacked on to the end of the standard sys.path. > BTW if you would like to use a registry module that has an easy to use > and really-pythonified interface you could also try out my pyRegistry > module (http://www.ultraemail.net/~jbj1). > > Jim Vickroy wrote: > > >I wish to conveniently test multiple versions of my Python application > >modules on a MS Windows platform. I want to avoid manually editing the > >Windows registry each time I want to modify the Python search path. Is > >modifying the contents of sys.path the way to do this and is use of the > >_winreg module API the best way to modify sys.path? > > > >Advice would be appreciated. Thanks. > > > > > >_______________________________________________ > >Python-win32 mailing list > >Python-win32@python.org > >http://mail.python.org/mailman/listinfo/python-win32 > > > > -- > Jens B. Jorgensen > jens.jorgensen@tallan.com From garber@centralcatholic.org Thu Mar 28 19:56:21 2002 From: garber@centralcatholic.org (Robert Garber) Date: Thu, 28 Mar 2002 14:56:21 -0500 Subject: [python-win32] py2exe HELP Message-ID: <200203281456.AA458097032@centralcatholic.org> Hello, I am crashing and burning. I have tried everything i can think of. I able to get everytihng in the same directory. at the DOS prmpt i type python setup.py py2exe. Everything seems smooht unitl it gets donw the screena bit then it says 'runtime error line 3 in ? RUNtime error: Something is wrong. So I oppne up the py2exe script. It tells me it has been replaced with the build_exe.py. So i edit my setup script to import build_exe. At the prompt I type python setup.py build_exe.That didnt work..Now I am getting a usage error that show 3 or 4 different ways to ask for help. and this one error: invalid command 'build_exe' (no class 'build_exe' in mdule 'distutils.command.build_exe')> enst step I assumed was to copy thebuild_exe in to distutils.command directory. That didnt work. I am still getting the same error. Any ideas on how to make this work? Thanks Robert From Jim.Vickroy@noaa.gov Thu Mar 28 21:20:26 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Thu, 28 Mar 2002 14:20:26 -0700 Subject: [python-win32] distutils question Message-ID: <3CA3891A.F7DE0E@noaa.gov> I have written my first, simple setup.py for use with the distutils module; I am experiencing some problems. When it is exexcuted, the following output is generated: running install running build running build_py creating build creating build\lib creating build\lib\GOES_12 creating build\lib\GOES_12\SXI creating build\lib\GOES_12\SXI\GDS creating build\lib\GOES_12\SXI\GDS\processor copying GOES_12\SXI\GDS\processor\__init__.py -> build\lib\GOES_12\SXI\GDS\processor copying GOES_12\SXI\GDS\processor\foo.py -> build\lib\GOES_12\SXI\GDS\processor running install_lib creating C:\Python22\Lib\site-packages\GOES_12 creating C:\Python22\Lib\site-packages\GOES_12\SXI creating C:\Python22\Lib\site-packages\GOES_12\SXI\GDS creating C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor copying build\lib\GOES_12\SXI\GDS\processor\foo.py -> C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor copying build\lib\GOES_12\SXI\GDS\processor\__init__.py -> C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor byte-compiling C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor\foo.py to foo.pyc byte-compiling C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor\__init__.py to __init__.pyc Everything looks fine; however, whenever I try to import it ... >>> import GOES_12.SXI.GDS.processor.foo Traceback (most recent call last): File "", line 1, in ? ImportError: No module named GOES_12.SXI.GDS.processor.foo What have I overlooked? Do I explicitly need to add the directory location to PYTHONPATH or the Windows registry? From Jim.Vickroy@noaa.gov Thu Mar 28 21:24:51 2002 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Thu, 28 Mar 2002 14:24:51 -0700 Subject: [python-win32] distutils cleanup failure Message-ID: <3CA38A23.B89B8E99@noaa.gov> Does the distutils "clean" option work on MS Win32 platforms? Here is the result on my computer: D:\my-py-pkgs\GOES-12-SXI-GDS-processor-v4.0>setup.py clean running clean warning: clean: 'build\temp.win32-2.2' does not exist -- can't clean it which is not surprising since the build directory created by "setup.py install" is not 'build\temp.win32-2.2'. From jens.jorgensen@tallan.com Thu Mar 28 22:38:45 2002 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Thu, 28 Mar 2002 16:38:45 -0600 Subject: [python-win32] distutils question References: <3CA3891A.F7DE0E@noaa.gov> Message-ID: <3CA39B75.1030508@tallan.com> Jim Vickroy wrote: >I have written my first, simple setup.py for use with the distutils >module; I am experiencing some problems. > >When it is exexcuted, the following output is generated: > >running install >running build >running build_py >creating build >creating build\lib >creating build\lib\GOES_12 >creating build\lib\GOES_12\SXI >creating build\lib\GOES_12\SXI\GDS >creating build\lib\GOES_12\SXI\GDS\processor >copying GOES_12\SXI\GDS\processor\__init__.py -> >build\lib\GOES_12\SXI\GDS\processor >copying GOES_12\SXI\GDS\processor\foo.py -> >build\lib\GOES_12\SXI\GDS\processor >running install_lib >creating C:\Python22\Lib\site-packages\GOES_12 >creating C:\Python22\Lib\site-packages\GOES_12\SXI >creating C:\Python22\Lib\site-packages\GOES_12\SXI\GDS >creating C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor >copying build\lib\GOES_12\SXI\GDS\processor\foo.py -> >C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor >copying build\lib\GOES_12\SXI\GDS\processor\__init__.py -> >C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor >byte-compiling >C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor\foo.py to >foo.pyc >byte-compiling >C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor\__init__.py to >__init__.pyc > > >Everything looks fine; however, whenever I try to import it ... > >>>>import GOES_12.SXI.GDS.processor.foo >>>> >Traceback (most recent call last): > File "", line 1, in ? >ImportError: No module named GOES_12.SXI.GDS.processor.foo > >What have I overlooked? Do I explicitly need to add the directory >location to PYTHONPATH or the Windows registry? > Oh, actually yeah, you have to do this also. distutils will create it for you but unless you subsequently you need to either a) change to the base directory distutils puts the module into (the directory that contains the directory GOES_12) or then actually install the modules with the installer it creates. -- Jens B. Jorgensen jens.jorgensen@tallan.com From niki@vintech.bg Fri Mar 29 09:06:54 2002 From: niki@vintech.bg (Niki Spahiev) Date: Fri, 29 Mar 2002 11:06:54 +0200 Subject: [python-win32] distutils question References: <3CA3891A.F7DE0E@noaa.gov> Message-ID: <3CA42EAE.3060502@vintech.bg> Jim Vickroy wrote: > I have written my first, simple setup.py for use with the distutils > module; I am experiencing some problems. > > When it is exexcuted, the following output is generated: > > running install > running build > running build_py > creating build > creating build\lib > creating build\lib\GOES_12 > creating build\lib\GOES_12\SXI > creating build\lib\GOES_12\SXI\GDS > creating build\lib\GOES_12\SXI\GDS\processor > copying GOES_12\SXI\GDS\processor\__init__.py -> > build\lib\GOES_12\SXI\GDS\processor > copying GOES_12\SXI\GDS\processor\foo.py -> > build\lib\GOES_12\SXI\GDS\processor > running install_lib > creating C:\Python22\Lib\site-packages\GOES_12 > creating C:\Python22\Lib\site-packages\GOES_12\SXI > creating C:\Python22\Lib\site-packages\GOES_12\SXI\GDS > creating C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor > copying build\lib\GOES_12\SXI\GDS\processor\foo.py -> > C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor > copying build\lib\GOES_12\SXI\GDS\processor\__init__.py -> > C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor > byte-compiling > C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor\foo.py to > foo.pyc > byte-compiling > C:\Python22\Lib\site-packages\GOES_12\SXI\GDS\processor\__init__.py to > __init__.pyc > > > Everything looks fine; however, whenever I try to import it ... > > >>>>import GOES_12.SXI.GDS.processor.foo >>> > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named GOES_12.SXI.GDS.processor.foo > > What have I overlooked? Do I explicitly need to add the directory > location to PYTHONPATH or the Windows registry? No but IMO you don't have __init__.py in GOES_12, GOES_12\SXI, GOES_12\SXI\GDS HTH Niki Spahiev From robinjim@earthlink.net Fri Mar 29 10:09:20 2002 From: robinjim@earthlink.net (robin and jim) Date: Fri, 29 Mar 2002 03:09:20 -0700 Subject: [python-win32] distutils question References: <3CA3891A.F7DE0E@noaa.gov> <3CA42EAE.3060502@vintech.bg> Message-ID: <000601c1d709$cc678b60$1cadbfa8@robinjim> Thanks for your response. Please see my comments below. ----- Original Message ----- From: "Niki Spahiev" To: "Jim Vickroy" Cc: Sent: Friday, March 29, 2002 2:06 AM Subject: Re: [python-win32] distutils question > Jim Vickroy wrote: > > I have written my first, simple setup.py for use with the distutils >> [snip] > > Everything looks fine; however, whenever I try to import it ... > > > > > >>>>import GOES_12.SXI.GDS.processor.foo > >>> > > Traceback (most recent call last): > > File "", line 1, in ? > > ImportError: No module named GOES_12.SXI.GDS.processor.foo > > > > What have I overlooked? Do I explicitly need to add the directory > > location to PYTHONPATH or the Windows registry? > > No but IMO you don't have __init__.py in GOES_12, GOES_12\SXI, > GOES_12\SXI\GDS > > HTH > Niki Spahiev > That is it exactly! When an __init__ module is added to each directory ( GOES_12, GOES_12\SXI, GOES_12\SXI\GDS) the import works without having to set PYTHONPATH or the MS Windows Registry. That is great! The question is: how should setup.py be implemented to automate this so that an __init__ module is placed in each directory as it is created during the build? From niki@vintech.bg Fri Mar 29 10:11:32 2002 From: niki@vintech.bg (Niki Spahiev) Date: Fri, 29 Mar 2002 12:11:32 +0200 Subject: [python-win32] distutils question References: <3CA3891A.F7DE0E@noaa.gov> <3CA42EAE.3060502@vintech.bg> <000601c1d709$cc678b60$1cadbfa8@robinjim> Message-ID: <3CA43DD4.4060400@vintech.bg> robin and jim wrote: >>No but IMO you don't have __init__.py in GOES_12, GOES_12\SXI, >>GOES_12\SXI\GDS >> >>HTH >>Niki Spahiev >> > > That is it exactly! > > When an __init__ module is added to each directory ( GOES_12, GOES_12\SXI, > GOES_12\SXI\GDS) the import works without having to set PYTHONPATH or the MS > Windows Registry. That is great! > > The question is: how should setup.py be implemented to automate this so that > an __init__ module is placed in each directory as it is created during the > build? Well IMHO this is not a task for setup.py but for module writer. Niki Spahiev From robinjim@earthlink.net Fri Mar 29 11:47:58 2002 From: robinjim@earthlink.net (robin and jim) Date: Fri, 29 Mar 2002 04:47:58 -0700 Subject: [python-win32] distutils question References: <3CA3891A.F7DE0E@noaa.gov> <3CA42EAE.3060502@vintech.bg> <000601c1d709$cc678b60$1cadbfa8@robinjim> <3CA43DD4.4060400@vintech.bg> Message-ID: <005701c1d717$9369f920$1cadbfa8@robinjim> ----- Original Message ----- From: "Niki Spahiev" To: "robin and jim" Cc: Sent: Friday, March 29, 2002 3:11 AM Subject: Re: [python-win32] distutils question > robin and jim wrote: [snip] > > When an __init__ module is added to each directory ( GOES_12, GOES_12\SXI, > > GOES_12\SXI\GDS) the import works without having to set PYTHONPATH or the MS > > Windows Registry. That is great! > > > > The question is: how should setup.py be implemented to automate this so that > > an __init__ module is placed in each directory as it is created during the > > build? > > Well IMHO this is not a task for setup.py but for module writer. > > Niki Spahiev > Perhaps you are correct, but if setup.py is to install a package, I want to make it do so without additional user effort (e.g., manually adding __init__ modules or updating the Windows registry). Some packages do this; I just have not, yet, discovered how they do so. From jeff@ccvcorp.com Fri Mar 29 17:28:15 2002 From: jeff@ccvcorp.com (Jeff Shannon) Date: Fri, 29 Mar 2002 09:28:15 -0800 Subject: [python-win32] distutils question References: Message-ID: <3CA4A42F.7D6439A8@ccvcorp.com> > > robin and jim wrote: > > > > The question is: how should setup.py be implemented to automate this so > that > > > an __init__ module is placed in each directory as it is created during > the > > > build? > > > > Well IMHO this is not a task for setup.py but for module writer. > > > > Niki Spahiev > > Perhaps you are correct, but if setup.py is to install a package, I want to > make it do so without additional user effort (e.g., manually adding __init__ > modules or updating the Windows registry). Some packages do this; I just > have not, yet, discovered how they do so. Creating the __init__.py is part of creating a package. It isn't part of installing it -- it should be done *before* using distutils to bundle up the package. Indeed, it's the presence of an __init__.py that *makes* a set of modules into a package, and __init__.py is used to control a number of details of how that package behaves (what modules it exports, etc). Note that Python uses the directory structure as part of the package structure. If I'm reading what you're doing properly, it looks to me like you may wish, instead of putting an __init__.py in each of a series of otherwise empty directories (empty of Python files anyhow), to change your directory structure so that your \processor directory is a direct subdirectory of site-packages. Then, you would import your package as import processor.foo possibly renaming processor to be a little more specific. Keep in mind that each segment of a name in an import statement (except the final one), is asking the interpreter to find a directory of that name and import the __init__.py file found in that directory. Jeff Shannon Technician/Programmer Credit International