From hameedkhaan at yahoo.com Sat Nov 1 12:47:30 2003 From: hameedkhaan at yahoo.com (Hameed Khan) Date: Sat Nov 1 12:47:36 2003 Subject: [python-win32] Thread Programming Message-ID: <20031101174730.99027.qmail@web20414.mail.yahoo.com> Hi, I am new to python. i have started 2 weeks ago. i want little help about registry manipulation. i see the _winreg module documentation come with python. but i didn't get any idea. i also googled for it but no results. so if anyone can give me a link to a tutorial on registry manipulation or a example code will be enough. so, i can learn from it. Thanks, Regards, Hameed. --------------------------------- Do you Yahoo!? Exclusive Video Premiere - Britney Spears -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031101/64485267/attachment.html From Duane.Kaufman at med.ge.com Mon Nov 3 09:24:11 2003 From: Duane.Kaufman at med.ge.com (Kaufman, Duane (MED, LUNAR)) Date: Mon Nov 3 09:25:15 2003 Subject: [python-win32] Problems with McMillan installer, and COM objects Message-ID: Hi, I am trying to get a Python-wxPython-COM program I have written into an 'installable' format to distribute it, and running into difficulties when installing it on another PC. My Python app utilizes an ActiveX OCX, and gets a reference to it through the gencache.EnsureModule() call. While this works OK on the development machine, when I package it up, and try it from another PC, it seems as if the directory names the win32com functions trying to use get goofed up. Has anyone successfully used Gordon's installer and an ActiveX component? Thanks in advance, Duane From hameedkhaan at yahoo.com Mon Nov 3 12:08:17 2003 From: hameedkhaan at yahoo.com (Hameed Khan) Date: Mon Nov 3 12:08:23 2003 Subject: [python-win32] Tkinter - can't close the console or interpreter window Message-ID: <20031103170817.20440.qmail@web20420.mail.yahoo.com> Hi, Sorry last time i post my question with the subject with no sense to my question. Because i was sleepy. Anyway, here is my another question. Today in morning i was learning to make a simple dialogue box with a quit button on it. Here is the code listing. #### Simple Dialogue Code from Tkinter import *# set up the window itselftop = Tk()F = Frame(top)F.pack()# add the widgetslHello = Label(F, text="Hello")lHello.pack()bQuit = Button(F, text="Quit", command=F.quit)bQuit.pack()# set the loop runningtop.mainloop() #### End The problem is that the typical interpreter window is appearing behind the dialogue box when i double click on my script file. anyidea how i can close that interpreter window so i will only get my dialogue box. Thanks, Regards, Hameed Khan. --------------------------------- Do you Yahoo!? Exclusive Video Premiere - Britney Spears -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031103/99276486/attachment.html From jens.jorgensen at tallan.com Mon Nov 3 12:28:13 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Mon Nov 3 12:30:01 2003 Subject: [python-win32] Thread Programming In-Reply-To: <20031101174730.99027.qmail@web20414.mail.yahoo.com> References: <20031101174730.99027.qmail@web20414.mail.yahoo.com> Message-ID: <3FA6902D.8010108@tallan.com> Well, how 'bout a little self-promotion! I wrote a little module called pyRegistry which gives nice a nice object-oriented interface to the registry. Take a look at my weak home page for more info (including full documentation): http://pitroda.net:8000/~jbj1 Hameed Khan wrote: > Hi, > I am new to python. i have started 2 weeks ago. i want little help > about registry manipulation. i see the _winreg module documentation > come with python. but i didn't get any idea. i also googled for it but > no results. so if anyone can give me a link to a tutorial on registry > manipulation or a example code will be enough. so, i can learn from it. > > Thanks, > Regards, > Hameed. > ------------------------------------------------------------------------ > Do you Yahoo!? > Exclusive Video Premiere - Britney Spears > > > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions." From jens.jorgensen at tallan.com Mon Nov 3 12:36:43 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Mon Nov 3 12:38:22 2003 Subject: [python-win32] Tkinter - can't close the console or interpreter window In-Reply-To: <20031103170817.20440.qmail@web20420.mail.yahoo.com> References: <20031103170817.20440.qmail@web20420.mail.yahoo.com> Message-ID: <3FA6922B.4020708@tallan.com> Rename your file with a .pyw extension. If you have the regular ActiveState python installation then doing so will associate the file with the pythonw.exe build. pythonw is build as a win32 gui app and the OS will not open a console window for it. This is a windoze thing rather than anything to do with Python. Hameed Khan wrote: > Hi, > Sorry last time i post my question with the subject with no sense to > my question. Because i was sleepy. Anyway, here is my another > question. Today in morning i was learning to make a simple dialogue > box with a quit button on it. Here is the code listing. > > #### Simple Dialogue Code > > >from Tkinter import * > ># set up the window itself >top = Tk() >F = Frame(top) >F.pack() > ># add the widgets >lHello = Label(F, text="Hello") >lHello.pack() >bQuit = Button(F, text="Quit", command=F.quit) >bQuit.pack() > ># set the loop running >top.mainloop() > > > > #### End > > The problem is that the typical interpreter window is appearing behind > the dialogue box when i double click on my script file. anyidea how i > can close that interpreter window so i will only get my dialogue box. > > Thanks, > Regards, > Hameed Khan. > ------------------------------------------------------------------------ > Do you Yahoo!? > Exclusive Video Premiere - Britney Spears > > > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions." From m_cannon at pacbell.net Tue Nov 4 13:32:05 2003 From: m_cannon at pacbell.net (Mike Cannon) Date: Tue Nov 4 13:37:26 2003 Subject: [python-win32] Problem with newer versions of win32all Message-ID: <16295.61605.468608.994264@gargle.gargle.HOWL> Hi, I'm having a problem with the newer version of win32all and Python 2.3 with code that works fine on Python-2.2 (details below). Both machines are Windows XP. The code that breaks is derived from the venerable jet2sql.py cookbook example. I added a routine that uses the daoEngine collection "TableDefs" and indexes it with a string (the table name). That works on Py-2.2/win32all-148 but not with Py-2.3/win32all-159. Any help ? Thanks in advance, Mike PS: I patched around this problem and the whole application seems fine in the new environment now. But I'd still like to know the root cause. ============================================================================ Code I added to jet2sql.py: ... self.dtbs = daoEngine.OpenDatabase(infile) ... ... 252: def tableGetPrimaryKey (self, tblName): 253: tbl = self.dtbs.TableDefs [ tblName ] # <<<< This breaks. 254: return self.getPrimaryKey ( tbl ) ... ============================================================================ Traceback: ... File "r:\FSRV\PROJECTS\Mello-et-al\jet2sql.py", line 253, in tableGetPrimaryKey tbl = self.dtbs.TableDefs [ tblName ] File "C:\DOCUME~1\cannon\LOCALS~1\Temp\gen_py\2.3\00025E01-0000-0000-C000-000000000046x0x5x0.py", line 1633, in __getitem__ return self._enum_.__getitem__(index) File "C:\Python23\lib\site-packages\win32com\client\util.py", line 37, in __getitem__ return self.__GetIndex(index) File "C:\Python23\lib\site-packages\win32com\client\util.py", line 42, in __GetIndex if type(index)!=type(0): raise TypeError, "Only integer indexes are supported for enumerators" TypeError: Only integer indexes are supported for enumerators ============================================================================ Old environment (works) - ACCESS 2000 / DAO 3.6 - Python 2.2 (ActiveState, from aspn.activestate.com April, '03) - win32all-148 - makepy on DAO 3.6 Object Library New Environment (breaks) - ACCESS 2000 / DAO 3.6 - Python 2.3 -- http://www.python.org/2.3.2/ --> Python-2.3.2-1.exe - win32all-159.exe -- http://starship.python.net/crew/mhammond/ - makepy on DAO 3.6 Object Library From koen_van_herck at yahoo.com Fri Nov 7 06:35:22 2003 From: koen_van_herck at yahoo.com (Koen Van Herck) Date: Fri Nov 7 06:35:24 2003 Subject: [python-win32] fix: GetIDsOfNames failed in event handler Message-ID: <002101c3a523$3cfe8f20$4028000a@KVanherck> Hi, I have encountered the following problem and was able to fix it. Please let me know if there are maybe better ways to fix the problem. First I create an object using Dispatch. Calling a method on this object returns me another object which implements events. So I've defined a class MyEventsThing, derived from makepy's generated IEventsThing class, which defines the event method OnSomeEvent. Then the event happens and the COM object tries to call my event handler using GetIDsOfNames with a name of SomeEvent. This fails because the _name_to_dispid_ table of the DesignatedWrapPolicy only contains OnSomeEvent. There are two things strange here: first, I wondered why I got DesignatedWrapPolicy instance instead of an EventHandlerPolicy instance. I could fix this by redefining the _query_interface_ method in my MyEventsThing class: def _query_interface_(self, iid): if iid==self.CLSID_Sink: return win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy) Is this maybe a bug in the makepy generated file (it doesn't specify the usePolicy) ? Once I fixed this, I added a _wrap_ method in the EventHandlerPolicy class: def _wrap_(self, ob): win32com.server.policy.EventHandlerPolicy._wrap_(self, ob) # Copy existing _dispid_to_func_ 'OnSomeEvent' entries # to _name_to_dispid_ 'SomeEvent' entries for dispid, name in self._dispid_to_func_.items(): if name[0:2].lower() == 'on': self._name_to_dispid_[name[2:].lower()]=dispid This will expose my OnSomeEvent method as SomeEvent, and everything works fine. Regards, Koen Van Herck. From mark at hubcapconsulting.com Fri Nov 7 16:23:54 2003 From: mark at hubcapconsulting.com (Mark Bucciarelli) Date: Fri Nov 7 16:44:21 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? Message-ID: <200311071623.54197.mark@hubcapconsulting.com> Stopping the service in the attached script times out (after a 30 second delay). The attached example will start/stop properly about five - eight times, and hang on the next start/stop cycle. The service does indeed get stopped, but Windows displays an error dialog. I've boiled it down to a small attached test case, but at this point I am stuck. Any suggestions most welcome! The attached test_service.py makes the following assumptions: (1) It assumes Python 22. (2) It assumes you will run these scripts from c:\temp. test.py assumes the log file is in c:\temp\test.log. To duplicate the behavior, c:\temp\>test_service.py install c:\temp\>test_service.py start c:\temp\>test_service.py stop ... repeat cycle, quickly and stop will hang c:\temp\>type test.log If you can duplicate the behavior, the log will have a section similar to the one I have attached. If you compare the log statements in test_service.py with the log output, you can see that that in the test_service.SimpleService.SvcStop() method, the call to win32event.SetEvent(self.hWaitStop) never completes. Also from the log, you can see that the loop in SvcDoRun does complete, so the the hWaitStop event is issued and caught. On a normal start/stop cycle, the end of the log looks like this: SvcStop 2 SvcStop 3 SvcStop complete <-- missing in attached log SvcDoRun: rc = 0 SvcDoRun complete A more complicated python script I am working on, started in a similar manner, times out much more frequently, at least four out of every five stop attempts. I am not subscribed to this list, so please cc me on any responses. Thanks for any help! Regards, -- Mark Bucciarelli, www.hubcapconsulting.com As we enjoy great advantages from inventions of others, we should be glad of an opportunity to serve others by any invention of ours; and this we should do freely and generously. -- Benjamin Franklin -------------- next part -------------- A non-text attachment was scrubbed... Name: test.log Type: text/x-log Size: 389 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20031107/b04ae73d/test.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: test.py Type: text/x-python Size: 372 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20031107/b04ae73d/test.py -------------- next part -------------- A non-text attachment was scrubbed... Name: test_service.py Type: text/x-python Size: 3729 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20031107/b04ae73d/test_service.py From gelbardn at tripwire.com Fri Nov 7 19:13:05 2003 From: gelbardn at tripwire.com (Nate Gelbard) Date: Fri Nov 7 19:13:12 2003 Subject: [python-win32] How to view Enumerated COM objects? Message-ID: <71767983FD626146999FBFFF445390EE156135@seabass.tripwire.com> Hello, I'm trying to make Excel batch process a bunch of XLS files into CSV. I have the basic operation working, but when the file already exists, a dialog pops up with 'Do you want to replace this file? Yes/No/Cancel.' I see the excel.ActiveWorkbook.SaveAs method has a ConflictResolution variable I can set (and am guessing this var affects that dialog box), but I don't know what to set it to. How can I take any COM objects and gets a list of all the expected constants? I tried the PythonWin COM browser but didn't get good answer. I bought the Python win32 book but am still trolling its pages. Any pointers? thanks --( Nate Gelbard, QA Engineer --( Tripwire, Inc., The Integrity Assurance Company From karl.fast at pobox.com Tue Nov 11 08:56:21 2003 From: karl.fast at pobox.com (Karl Fast) Date: Tue Nov 11 08:57:00 2003 Subject: [python-win32] win32com on activepython 2.3 Message-ID: <20031111075621.D19770@signal.lights.com> Upgrading to ActivePython 2.3 seems to have broken something with win32com. I can't import win32com.client. There might be other problems, but I can't get past this. Importing win32com.client gives you this traceback: >>>import win32com.client Traceback (most recent call last): File "", line 1, in ? File "D:\python\Lib\site-packages\win32com\client\__init__.py", line 12, in ? import dynamic, gencache, pythoncom File "D:\python\Lib\site-packages\win32com\client\gencache.py", line 623, in ? __init__() File "D:\python\Lib\site-packages\win32com\client\gencache.py", line 52, in __init__ Rebuild() File "D:\python\Lib\site-packages\win32com\client\gencache.py", line 610, in Rebuild _SaveDicts() File "D:\python\Lib\site-packages\win32com\client\gencache.py", line 57, in _SaveDicts raise RuntimeError, "Trying to write to a readonly gencache ('%s')!" \ RuntimeError: Trying to write to a readonly gencache ('C:\DOCUME~1\fast\LOCALS~1\Temp\gen_py\2.3')! It all worked until I upgraded from ActivePython 2.2 I can go back to 2.2, but I don't know if this is (a) a problem with the latest ActivePython (b) a problem with the latest win32 extensions (c) me doing something wrong and getting away with in 2.2 (I am new to python, but this is straight out of the examples) Anyone able to help? In my code I'm actually importing it like this, but I still get the same "trying to write to a readonly gencache" error.... from win32com.client import constants, Dispatch --karl From jens.jorgensen at tallan.com Tue Nov 11 10:42:43 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Nov 11 10:45:30 2003 Subject: [python-win32] win32com on activepython 2.3 In-Reply-To: <20031111075621.D19770@signal.lights.com> References: <20031111075621.D19770@signal.lights.com> Message-ID: <3FB10373.70000@tallan.com> I've heard another report as well. Someone used makepy.py to generate a wrapper for the visual sourcesafe typelib. This failed initially because the relocated genpy cache didn't have directories created (I believe I saw in the changelog this is now fixed) but even after that he got an error from the module when it was imported. It truly seems like something's broken in there. Anyhow the error you're reporting is just the problem with the gencache. You need to create the missing directories in that path it lists for the gencache and that will solve that problem. Karl Fast wrote: >Upgrading to ActivePython 2.3 seems to have broken something with >win32com. I can't import win32com.client. There might be other >problems, but I can't get past this. > >Importing win32com.client gives you this traceback: > > > >>>>import win32com.client >>>> >>>> > >Traceback (most recent call last): > File "", line 1, in ? > File "D:\python\Lib\site-packages\win32com\client\__init__.py", > line 12, in ? > import dynamic, gencache, pythoncom > File "D:\python\Lib\site-packages\win32com\client\gencache.py", > line 623, in ? __init__() > File "D:\python\Lib\site-packages\win32com\client\gencache.py", > line 52, in __init__ > Rebuild() > File "D:\python\Lib\site-packages\win32com\client\gencache.py", > line 610, in Rebuild > _SaveDicts() > File "D:\python\Lib\site-packages\win32com\client\gencache.py", > line 57, in _SaveDicts > raise RuntimeError, "Trying to write to a readonly gencache > ('%s')!" \ RuntimeError: Trying to write to a readonly gencache > ('C:\DOCUME~1\fast\LOCALS~1\Temp\gen_py\2.3')! > > >It all worked until I upgraded from ActivePython 2.2 > >I can go back to 2.2, but I don't know if this is > > (a) a problem with the latest ActivePython > (b) a problem with the latest win32 extensions > (c) me doing something wrong and getting away with in 2.2 (I am > new to python, but this is straight out of the examples) > >Anyone able to help? > >In my code I'm actually importing it like this, but I still get the >same "trying to write to a readonly gencache" error.... > > from win32com.client import constants, Dispatch > > > >--karl > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions." From karl.fast at pobox.com Tue Nov 11 12:19:38 2003 From: karl.fast at pobox.com (Karl Fast) Date: Tue Nov 11 12:20:20 2003 Subject: [python-win32] resizing excel comment fields Message-ID: <20031111111938.D1233@signal.lights.com> I'm trying to resize comments for individual cells in an excel worksheet (loong story). Can't make it work. I can do things like this: obj.Cells(row, col).ClearComments() obj.Cells(row, col).AddComment() obj.Cells(row, col).Comment.Text(Text = 'blah') What I need to do is, for a given cell (just one, not a range), - create a comment (clear comment if it already exists) - add some text - resize comment box (make it several times wider than the default since my comments are very long strings). I'm new to COM and the docs aren't helping me much. I created an excel macro and looked through that, but I'm unable to translate it python. There's stuff about selecting shape objects and then using the ScaleWidth method. Can't make it work. Ideas? --karl From bgailer at alum.rpi.edu Tue Nov 11 13:53:50 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Nov 11 13:56:06 2003 Subject: [python-win32] Problem with new install Message-ID: <6.0.0.22.0.20031111115027.032623e0@mail.mric.net> I was getting some incomprehensible and inexplicible errors communicating with Excel, so I "upgraded" from win32all 150 to 154. Now when I start running under the debugger I get: Traceback (most recent call last): File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 35, in _GetCurrentDebugger _CheckNeedGUI() File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 21, in _CheckNeedGUI pywin.framework.app.CreateDefaultGUI(dbgpyapp.DebuggerPythonApp) File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\app.py", line 392, in CreateDefaultGUI appClass().InitInstance() File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\dbgpyapp.py", line 33, in InitInstance win32ui.LoadStdProfileSettings(numMRU) win32ui: The profile settings have already been loaded. Things have gone from bad to worse, because now I can't run any programs. What should I do? Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003 From bgailer at alum.rpi.edu Tue Nov 11 14:05:30 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Nov 11 14:07:45 2003 Subject: [python-win32] Original Problem Message-ID: <6.0.0.22.0.20031111115704.031655e0@mail.mric.net> In my previous e-mail I mentioned a problem communication with excel. Here is the code (note that graph_base.xls has a blank chart on it): ----------------i:\samis\python\super_out.py------------------------------------ import win32com.client ex = win32com.client.Dispatch("excel.application");ex.Visible = 1 wb = ex.Workbooks.Open('i:\\samis\\data\\graph_base.xls') sheets = ex.Worksheets.Count ex.Worksheets(1).Copy(None, ex.Worksheets(1)) wk2 = ex.Worksheets(sheets + 1) co = wk2.ChartObjects(1) ch = co.Chart ch.ChartType = 4 # xlLine series_range = ex.Range("C25:D27") ch.SeriesCollection().Add(series_range, 2) ------------------------------------------------------------ and here is the error (on my client's machine, under win32all 150 ------------------------------------------------------------ File "i:\samis\python\super_out.py", line 11 ch.SeriesCollection().Add(series_range, 2) File "", line 3, in Add File "C:\Python22\lib\site-packages\win32com\client\__init__.py", line 93, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Python22\lib\site-packages\win32com\client\__init__.py", line 41, in __WrapDispatch return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, UnicodeToString=UnicodeToString,clsctx=clsctx) File "C:\Python22\lib\site-packages\win32com\client\dynamic.py", line 90, in Dispatch typeinfo = IDispatch.GetTypeInfo() AttributeError: 'int' object has no attribute 'GetTypeInfo' ------------------------------------------------------------ This error does not happen on my machine (under win32all 154) Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003 From bgailer at alum.rpi.edu Tue Nov 11 14:24:00 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Nov 11 14:26:13 2003 Subject: [python-win32] Same error in 162 Message-ID: <6.0.0.22.0.20031111122329.03255560@mail.mric.net> I upgraded to win32all 162; same problem. Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003 From bgailer at alum.rpi.edu Tue Nov 11 14:51:26 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Nov 11 14:53:43 2003 Subject: [python-win32] test Message-ID: <6.0.0.22.0.20031111125117.032b7128@mail.mric.net> test Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003 From lourie at 21cn.com Wed Nov 12 00:17:55 2003 From: lourie at 21cn.com (lourie) Date: Wed Nov 12 00:25:28 2003 Subject: [python-win32] Problem about py2exe. Thanks Message-ID: <522330906.20031112131755@21cn.com> Hello python-win32, When using py2exe to generate a exe file on Windows2000 server and trying to run the file, I met the problem: Traceback (most recent call last): File "", line 1, in ? File "imputil.pyc", line 106, in _import_hook ImportError: No module named wxPython.wx But I could use 'python Attribute.py' to run properly. And I found in the following messages that wxPython is found. What's wrong? Thanks. running py2exe running build running build_scripts running install_scripts creating build\bdist.win32\winexe creating build\bdist.win32\winexe\lib creating build\bdist.win32\winexe\lib\Python22 creating build\bdist.win32\winexe\lib\Python22\Scripts copying build\scripts-2.2\AttributeP.py -> build\bdist.win32\winexe\lib\Python22 \Scripts +---------------------------------------------------- | Processing script AttributeP.py with py2exe-0.3.3 +---------------------------------------------------- creating build\bdist.win32\winexe\collect creating build\bdist.win32\winexe\collect\AttributeP creating build\bdist.win32\winexe\collect\AttributeP\Scripts.py2exe Searching modules needed to run 'AttributeP.py' on path: ['E:\\work\\python\\mycode\\wychi\\build\\bdist.win32\\winexe\\lib\\Python22\\Li b\\site-packages', '', 'D:\\Python22', 'E:\\work\\python\\mycode\\wychi', 'D:\\P ython22\\DLLs', 'D:\\Python22\\lib', 'D:\\Python22\\lib\\lib-tk', 'D:\\Python22\ \lib\\site-packages', 'D:\\Python22\\lib\\site-packages\\PIL'] force_imports = Resolving binary dependencies: D:\Python22\lib\site-packages\wxPython\wxc.pyd C:\WINNT\system32\python22.dll D:\Python22\lib\site-packages\_mysql.pyd D:\Python22\lib\site-packages\wxPython\wizardc.pyd D:\Python22\lib\site-packages\wxPython\wxmsw24h.dll D:\Python22\lib\site-packages\wxPython\gridc.pyd D:\Python22\DLLs\_sre.pyd D:\Python22\lib\site-packages\py2exe\run.exe ext_mapping = { 'wxPython.wizardc': ('wizardc.pyd', ('.pyd', 'rb', 3)) '_sre': ('_sre.pyd', ('.pyd', 'rb', 3)) 'wxPython.gridc': ('gridc.pyd', ('.pyd', 'rb', 3)) 'wxPython.wxc': ('wxc.pyd', ('.pyd', 'rb', 3)) '_mysql': ('_mysql.pyd', ('.pyd', 'rb', 3)) } copying D:\Python22\lib\site-packages\py2exe\support.py -> build\bdist.win32\win exe\collect\AttributeP\Scripts.py2exe byte-compiling D:\Python22\lib\pre.py to pre.pyc byte-compiling D:\Python22\lib\site-packages\MySQLdb\converters.py to MySQLdb\co nverters.pyc byte-compiling D:\Python22\lib\__future__.py to __future__.pyc byte-compiling D:\Python22\lib\copy_reg.py to copy_reg.pyc byte-compiling D:\Python22\lib\site-packages\wxPython\fonts.py to wxPython\fonts .pyc byte-compiling D:\Python22\lib\site-packages\wxPython\windows.py to wxPython\win dows.pyc ... byte-compiling D:\Python22\lib\site-packages\wxPython\wizard.py to wxPython\wiza rd.pyc byte-compiling D:\Python22\lib\site-packages\wxPython\events.py to wxPython\even ts.pyc ... creating dist\AttributeP\AttributeP.exe warning: py2exe: *************************************************************** ********** warning: py2exe: * The following modules were not found: warning: py2exe: * cmndlgsc warning: py2exe: * utilsc warning: py2exe: * clip_dndc warning: py2exe: * DateTime warning: py2exe: * windows3c warning: py2exe: * filesysc warning: py2exe: * eventsc warning: py2exe: * windows2c warning: py2exe: * controlsc warning: py2exe: * mx.DateTime warning: py2exe: * misc2c warning: py2exe: * windowsc warning: py2exe: * stattoolc warning: py2exe: * mdic warning: py2exe: * gdic warning: py2exe: * sizersc warning: py2exe: * printfwc warning: py2exe: * fontsc warning: py2exe: * imagec warning: py2exe: * streamsc warning: py2exe: * miscc warning: py2exe: * controls2c warning: py2exe: * framesc warning: py2exe: *************************************************************** ********** removing 'build\bdist.win32\winexe\collect\AttributeP' (and everything under it) Built File dist\AttributeP\AttributeP.exe removing 'build\bdist.win32\winexe' (and everything under it) -- Best regards, lourie mailto:lourie@21cn.com From shamsul at handisplay.com.my Wed Nov 12 23:57:23 2003 From: shamsul at handisplay.com.my (Shamsul Azhar) Date: Wed Nov 12 23:57:31 2003 Subject: [python-win32] Controling MS word from Pytonwin Message-ID: Hi, I'm currently writing an application to control MS-Word from Pythonwin. At the moment I'm having problems trying to activate a menu option in word. The following code snippets should start Word and activate the "Open" menu option. Using VB the code would look something like :- Private Sub Command1_Click() Dim wordApp As Word.Application Set wordApp = CreateObject("Word.Application") wordApp.Visible = True wordApp.CommandBars.FindControl(ID:=23).Execute End Sub Which when translates to Pythonwin would look like :- wordApp = win32com.client.Dispatch("word.Application") wordApp.visible = 1 wordApp.CommandBars.FindControl(Id=23).Execute However it works fine in VB but in Pythonwin failed to execute the "Open" menu option. Hope somebody can help. TIA. From theller at python.net Thu Nov 13 02:57:23 2003 From: theller at python.net (Thomas Heller) Date: Thu Nov 13 02:57:43 2003 Subject: [python-win32] Re: Controling MS word from Pytonwin References: Message-ID: "Shamsul Azhar" writes: > Hi, > > I'm currently writing an application to control MS-Word from Pythonwin. At > the moment I'm having problems trying to activate a menu option in word. > The following code snippets should start Word and activate the "Open" menu > option. > > Using VB the code would look something like :- > > Private Sub Command1_Click() > Dim wordApp As Word.Application > Set wordApp = CreateObject("Word.Application") > wordApp.Visible = True > > wordApp.CommandBars.FindControl(ID:=23).Execute > End Sub > > Which when translates to Pythonwin would look like :- > > wordApp = win32com.client.Dispatch("word.Application") > wordApp.visible = 1 > wordApp.CommandBars.FindControl(Id=23).Execute The last line, when executed in the interactive interpreter, prints > so you only retrieve the method, but do not call it. Change it to > wordApp.CommandBars.FindControl(Id=23).Execute() and it should work. Thomas From master at hilug.org Thu Nov 13 23:58:52 2003 From: master at hilug.org (Y.H. Rhiu) Date: Thu Nov 13 23:59:04 2003 Subject: [python-win32] Re: Controling MS word from Pytonwin References: Message-ID: <000d01c3aa6c$00b752b0$ca3fe7cb@LocalHost> I think Mr.Azhar would like to activate the "Open" menu, such as pushing Ctrl+o key. But "wordApp.CommandBars.FindControl(Id=23).Execute()" only open a new document, not activate Open menu. How about this code: wordApp.CommandBars.FindControl(Type=1,Id=23).Execute() Rhiu > "Shamsul Azhar" writes: > > > Hi, > > > > I'm currently writing an application to control MS-Word from Pythonwin. At > > the moment I'm having problems trying to activate a menu option in word. > > The following code snippets should start Word and activate the "Open" menu > > option. > > > > Using VB the code would look something like :- > > > > Private Sub Command1_Click() > > Dim wordApp As Word.Application > > Set wordApp = CreateObject("Word.Application") > > wordApp.Visible = True > > > > wordApp.CommandBars.FindControl(ID:=23).Execute > > End Sub > > > > Which when translates to Pythonwin would look like :- > > > > wordApp = win32com.client.Dispatch("word.Application") > > wordApp.visible = 1 > > wordApp.CommandBars.FindControl(Id=23).Execute > > The last line, when executed in the interactive interpreter, prints > > > so you only retrieve the method, but do not call it. > Change it to > > wordApp.CommandBars.FindControl(Id=23).Execute() > and it should work. > > Thomas > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From shamsul at handisplay.com.my Fri Nov 14 02:19:40 2003 From: shamsul at handisplay.com.my (Shamsul Azhar) Date: Fri Nov 14 02:19:50 2003 Subject: [python-win32] Controling MS word from Pytonwin In-Reply-To: Message-ID: > Hi, > > I'm currently writing an application to control MS-Word from Pythonwin. At > the moment I'm having problems trying to activate a menu option in word. > The following code snippets should start Word and activate the "Open" menu > option. > > Using VB the code would look something like :- > > Private Sub Command1_Click() > Dim wordApp As Word.Application > Set wordApp = CreateObject("Word.Application") > wordApp.Visible = True > > wordApp.CommandBars.FindControl(ID:=23).Execute > End Sub > > Which when translates to Pythonwin would look like :- > > wordApp = win32com.client.Dispatch("word.Application") > wordApp.visible = 1 > wordApp.CommandBars.FindControl(Id=23).Execute The last line, when executed in the interactive interpreter, prints > so you only retrieve the method, but do not call it. Change it to > wordApp.CommandBars.FindControl(Id=23).Execute() and it should work. Hi, Thanks for your reply. My actual code is wordApp.CommandBars.FindControl(Id=23).Execute() sorry for the typo. This should start word and simulate a user selecting the "File->Open" menu option, as a result the 'Open' dilog box would appear (trust me I need to do it this way......looong story). in VB the following code using keyword parameter works (it also works in C# using default parametres) :- wordApp.CommandBars.FindControl(ID:=23).Execute I found out that the that using keyword parameter in python like so :- wordApp.CommandBars.FindControl(Id=23).Execute() doesn't work exactly as expected. If I were to modify the python code to :- self.app.CommandBars.FindControl(1, 23, "", 1).Execute() then it works. Hmmm.... is there a good explanation for this? Thanks again for your help. Regards. From simon at meru.org.uk Wed Nov 19 10:01:55 2003 From: simon at meru.org.uk (Simon Judge) Date: Wed Nov 19 09:52:49 2003 Subject: [python-win32] KeyDownEvents whilst minimised/background Message-ID: Hi, Anyone got any ideas how it would be possible to 'catch' key presses whilst the python program does NOT have focus? Ideally as a Sys-tray program.... Thanks. Simon From darkbard at email.it Fri Nov 21 03:28:20 2003 From: darkbard at email.it (darkbard) Date: Fri Nov 21 03:28:25 2003 Subject: [python-win32] How can I register a python program to run as a service?? Message-ID: Hi guys, I'm new in python-win32 development. I'd like to know if and how I can make my python program to run as a service for all users. In addition a'd like to know how can I automatically associate a file extension to a specific python program. txn a lot From jhmsmits at xs4all.nl Fri Nov 21 04:35:10 2003 From: jhmsmits at xs4all.nl (Sander Smits) Date: Fri Nov 21 04:35:18 2003 Subject: [python-win32] opening and closing applications Message-ID: <200311211035.10603.jhmsmits@xs4all.nl> Hi, I'm new to python-win32 programming. Could anyone tell me how to open and close non-office applications? I would like them (*.exe's) to open as a background process. I tried it the ugly way by invoking os.system, but then it was impossible to close it. Regards, Sander. From felix_mcallister at hotmail.com Fri Nov 21 06:37:48 2003 From: felix_mcallister at hotmail.com (Felix McAllister) Date: Fri Nov 21 06:37:54 2003 Subject: [python-win32] Path to the service script Message-ID: Hi, I've noticed that the path to the service script is the last element in sys.path i.e. sys.path[-1] and not sys.path[0]. Is this deliberate and can I rely on this? Felix. _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 From Jim.Vickroy at noaa.gov Fri Nov 21 10:32:35 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Nov 21 10:32:45 2003 Subject: [python-win32] How can I register a python program to run as aservice?? References: Message-ID: <3FBE3013.8D706D8E@noaa.gov> darkbard wrote: > Hi guys, > > I'm new in python-win32 development. I'd like to know if and how I can make > my python program to run as a service for all users. > #! BEGIN SCRIPT # SmallestService.py # # A sample demonstrating the smallest possible service written in Python. import win32serviceutil import win32service import win32event class SmallestPythonService(win32serviceutil.ServiceFramework): _svc_name_ = "SmallestPythonService" _svc_display_name_ = "The smallest possible Python Service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) # Create an event which we will use to wait on. # The "service stop" request will set this event. self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): # Before we do anything, tell the SCM we are starting the stop process. self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) # And set my event. win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): # We do nothing other than wait to be stopped! win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) if __name__=='__main__': import sys #! jv print '\n\n\targs[0]: %s\n' % sys.argv[0] #! jv import SmallestService #! jv print '\n\n\tfile: %s\n' % SmallestService.__file__ #! jv print '\n\nServiceClassString: %s\n' % win32serviceutil.GetServiceClassString(SmallestPythonService) #! dbug win32serviceutil.HandleCommandLine(SmallestPythonService) #! END SCRIPT If you do not have a copy of the book "Python Programming on Win32" by Mark Hammond and Andy Robinson, you should consider getting it. Although it assumes an earlier version of Python, the information is still very valuable. > > In addition a'd like to know how can I automatically associate a file > extension to a specific python program. > > txn a lot > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From Jim.Vickroy at noaa.gov Fri Nov 21 10:35:49 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Nov 21 10:36:09 2003 Subject: [python-win32] opening and closing applications References: <200311211035.10603.jhmsmits@xs4all.nl> Message-ID: <3FBE30D4.18783665@noaa.gov> Sander Smits wrote: > Hi, > > I'm new to python-win32 programming. Could anyone tell me how to open and > close non-office applications? I would like them (*.exe's) to open as a > background process. > I tried it the ugly way by invoking os.system, but then it was impossible to > close it. > #! BEGIN SCRIPT # CreateProcess.py # # Demo of creating two processes using the CreateProcess API, # then waiting for the processes to terminate. import win32process import win32event import win32con import win32api # Create a process specified by commandLine, and # The process' window should be at position rect # Returns the handle to the new process. def CreateMyProcess( commandLine, rect): # Create a STARTUPINFO object si = win32process.STARTUPINFO() # Set the position in the startup info. si.dwX, si.dwY, si.dwXSize, si.dwYSize = rect # And indicate which of the items are valid. si.dwFlags = win32process.STARTF_USEPOSITION | \ win32process.STARTF_USESIZE # Rest of startup info is default, so we leave it alone. # Create the process. info = win32process.CreateProcess( None, # AppName commandLine, # Command line None, # Process Security None, # ThreadSecurity 0, # Inherit Handles? win32process.NORMAL_PRIORITY_CLASS, None, # New environment None, # Current directory win32process.STARTUPINFO()) # startup info. ##si) # startup info. # Return the handle to the process. # Recall info is a tuple of (hProcess, hThread, processId, threadId) return info[0] def RunEm(): handles = [] # First get the screen size to calculate layout. screenX = win32api.GetSystemMetrics(win32con.SM_CXSCREEN) screenY = win32api.GetSystemMetrics(win32con.SM_CYSCREEN) # First instance will be on the left hand side of the screen. rect = 0, 0, screenX/2, screenY handle = CreateMyProcess("notepad", rect) handles.append(handle) # Second instance of Notepad will be on the right hand side. rect = screenX/2+1, 0, screenX/2, screenY handle = CreateMyProcess("notepad", rect) handles.append(handle) # Now we have the processes, wait for them both # to terminate. # Rather than waiting the whole time, we loop 10 times, # waiting for one second each time, printing a message # each time around the loop countdown = range(1,10) countdown.reverse() for i in countdown: print "Waiting %d seconds for apps to close" % i rc = win32event.WaitForMultipleObjects( handles, # Objects to wait for. 1, # Wait for them all 1000) # timeout in milli-seconds. if rc == win32event.WAIT_OBJECT_0: # Our processes closed! print "Our processes closed in time." break # else just continue around the loop. else: # We didn't break out of the for loop! print "Giving up waiting - killing processes" for handle in handles: try: win32process.TerminateProcess(handle, 0) except win32process.error: # This one may have already stopped. pass if __name__=='__main__': RunEm() #! END SCRIPT > > Regards, Sander. > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jhmsmits at xs4all.nl Fri Nov 21 16:44:06 2003 From: jhmsmits at xs4all.nl (Sander Smits) Date: Fri Nov 21 16:44:14 2003 Subject: [python-win32] opening and closing applications In-Reply-To: <3FBE30D4.18783665@noaa.gov> References: <200311211035.10603.jhmsmits@xs4all.nl> <3FBE30D4.18783665@noaa.gov> Message-ID: <200311212244.06542.jhmsmits@xs4all.nl> Thanks, this is exactly what I need. Op vrijdag 21 november 2003 16:35, schreef u: > Sander Smits wrote: > > Hi, > > > > I'm new to python-win32 programming. Could anyone tell me how to open and > > close non-office applications? I would like them (*.exe's) to open as a > > background process. > > I tried it the ugly way by invoking os.system, but then it was impossible > > to close it. > > #! BEGIN SCRIPT > # CreateProcess.py > # > # Demo of creating two processes using the CreateProcess API, > # then waiting for the processes to terminate. > > import win32process > import win32event > import win32con > import win32api > > # Create a process specified by commandLine, and > # The process' window should be at position rect > # Returns the handle to the new process. > def CreateMyProcess( commandLine, rect): > # Create a STARTUPINFO object > si = win32process.STARTUPINFO() > # Set the position in the startup info. > si.dwX, si.dwY, si.dwXSize, si.dwYSize = rect > # And indicate which of the items are valid. > si.dwFlags = win32process.STARTF_USEPOSITION | \ > win32process.STARTF_USESIZE > # Rest of startup info is default, so we leave it alone. > # Create the process. > info = win32process.CreateProcess( > None, # AppName > commandLine, # Command line > None, # Process Security > None, # ThreadSecurity > 0, # Inherit Handles? > win32process.NORMAL_PRIORITY_CLASS, > None, # New environment > None, # Current directory > win32process.STARTUPINFO()) # startup info. > ##si) # startup info. > # Return the handle to the process. > # Recall info is a tuple of (hProcess, hThread, processId, threadId) > return info[0] > > def RunEm(): > handles = [] > # First get the screen size to calculate layout. > screenX = win32api.GetSystemMetrics(win32con.SM_CXSCREEN) > screenY = win32api.GetSystemMetrics(win32con.SM_CYSCREEN) > # First instance will be on the left hand side of the screen. > rect = 0, 0, screenX/2, screenY > handle = CreateMyProcess("notepad", rect) > handles.append(handle) > # Second instance of Notepad will be on the right hand side. > rect = screenX/2+1, 0, screenX/2, screenY > handle = CreateMyProcess("notepad", rect) > handles.append(handle) > > # Now we have the processes, wait for them both > # to terminate. > # Rather than waiting the whole time, we loop 10 times, > # waiting for one second each time, printing a message > # each time around the loop > countdown = range(1,10) > countdown.reverse() > for i in countdown: > print "Waiting %d seconds for apps to close" % i > rc = win32event.WaitForMultipleObjects( > handles, # Objects to wait for. > 1, # Wait for them all > 1000) # timeout in milli-seconds. > if rc == win32event.WAIT_OBJECT_0: > # Our processes closed! > print "Our processes closed in time." > break > # else just continue around the loop. > else: > # We didn't break out of the for loop! > print "Giving up waiting - killing processes" > for handle in handles: > try: > win32process.TerminateProcess(handle, 0) > except win32process.error: > # This one may have already stopped. > pass > > if __name__=='__main__': > RunEm() > > #! END SCRIPT > > > Regards, Sander. > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 From mark at hubcapconsulting.com Fri Nov 21 17:49:47 2003 From: mark at hubcapconsulting.com (Mark Bucciarelli) Date: Fri Nov 21 17:49:10 2003 Subject: [python-win32] How can I register a python program to run as aservice?? In-Reply-To: <3FBE3013.8D706D8E@noaa.gov> References: <3FBE3013.8D706D8E@noaa.gov> Message-ID: <200311211749.47745.mark@hubcapconsulting.com> On Friday 21 November 2003 10:32 am, Jim Vickroy wrote: > # SmallestService.py Yes, indeed! :) I posted a couple week ago about being able to get a stop command timeout and I was able to duplicate this behavior reliably with your sample script. Here's how: install this service and run through four or five start/stop cycles in rapid succession, and the stop command will time out with the following message: Stopping service SmallestPythonService Error stopping service: The service did not respond to the start or control request in a timely fashion. (1053) The event viewer has the following event: Timeout (30000 milliseconds) waiting for a transaction response from the SmallestPythonServer service. The stop command is timing out pretty consistently on other machines when the service does more. You can also "kind of" duplicate this pretty easily--by adding a time.sleep(1) just before the SetEvent in SvcStop, I was able to get the stop command to time out on the second cycle. I have seen this timeout both on Windows 2000 and Windows XP Home. Note that the service actually does stop; that is, while the SetEvent never returns, the SvcDoRun method does exit. Regards, Mark From janez.jere at void.si Sun Nov 23 14:53:43 2003 From: janez.jere at void.si (Janez Jere) Date: Sun Nov 23 14:53:10 2003 Subject: [python-win32] makepy 0.4.8 != 0.4.6 in build 163 Message-ID: I found different behaviour of gencache.EnsureModule in latest version of win32com, because generated script differs from previous builds. In my opinion generated code with makepy_version == '0.4.8' is not correct. (I checked IDL). statement: msxmlTyp=gencache.EnsureModule('{F5078F18-C551-11D3-89B9-0000F81FE221}', 0, 4, 0) will generate a file, where all open methods (def open) will be capitalised (def Open). could someone confirm my findings? Janez here is a diff (-w -u): --- old\F5078F18-C551-11D3-89B9-0000F81FE221x0x4x0.py 2003-11-21 15:42:41.718750000 +0100 +++ F5078F18-C551-11D3-89B9-0000F81FE221x0x4x0.py 2003-11-21 15:35:51.671875000 +0100 @@ -1,13 +1,14 @@ # -*- coding: mbcs -*- -# Created by makepy.py version 0.4.6 -# By python version 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] +# Created by makepy.py version 0.4.8 +# By python version 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] # From type library '{F5078F18-C551-11D3-89B9-0000F81FE221}' -# On Fri Nov 21 15:42:41 2003 +# On Fri Nov 21 15:35:51 2003 """Microsoft XML, v4.0""" -makepy_version = '0.4.6' -python_version = 0x20301f0 +makepy_version = '0.4.8' +python_version = 0x20302f0 import win32com.client.CLSIDToClass, pythoncom +import win32com.client.util from pywintypes import IID from win32com.client import Dispatch @@ -259,13 +260,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -638,13 +642,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -749,13 +756,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -825,7 +835,7 @@ # Result is a Unicode object - return as-is for this version of Python return self._oleobj_.InvokeTypes(3, LCID, 1, (8, 0), ((8, ,),bstrHeader) - def open(self, bstrMethod=defaultNamedNotOptArg, bstrUrl=defaultNamedNotOptArg, varAsync=defaultNamedOptArg, bstrUser=defaultNamedOptArg, bstrPassword=defaultNamedOptArg): + def Open(self, bstrMethod=defaultNamedNotOptArg, bstrUrl=defaultNamedNotOptArg, varAsync=defaultNamedOptArg, bstrUser=defaultNamedOptArg, bstrPassword=defaultNamedOptArg): """Open HTTP connection""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((8, 1), (8, 1), (12, 17), (12, 17), (12, 17)),bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword) @@ -885,7 +895,7 @@ # Result is a Unicode object - return as-is for this version of Python return self._oleobj_.InvokeTypes(3, LCID, 1, (8, 0), ((8, ,),bstrHeader) - def open(self, bstrMethod=defaultNamedNotOptArg, bstrUrl=defaultNamedNotOptArg, varAsync=defaultNamedOptArg, bstrUser=defaultNamedOptArg, bstrPassword=defaultNamedOptArg): + def Open(self, bstrMethod=defaultNamedNotOptArg, bstrUrl=defaultNamedNotOptArg, varAsync=defaultNamedOptArg, bstrUser=defaultNamedOptArg, bstrPassword=defaultNamedOptArg): """Open HTTP connection""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((8, 1), (8, 1), (12, 17), (12, 17), (12, 17)),bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword) @@ -1924,9 +1934,9 @@ return ret # Result is of type IXMLDOMNode - def createNode(self, type=defaultNamedNotOptArg, name=defaultNamedNotOptArg, namespaceURI=defaultNamedNotOptArg): + def createNode(self, Type=defaultNamedNotOptArg, name=defaultNamedNotOptArg, namespaceURI=defaultNamedNotOptArg): """create a node of the specified node type and name""" - ret = self._oleobj_.InvokeTypes(54, LCID, 1, (9, 0), ((12, 1), (8, 1), (8, 1)),type, name, namespaceURI) + ret = self._oleobj_.InvokeTypes(54, LCID, 1, (9, 0), ((12, 1), (8, 1), (8, 1)),Type, name, namespaceURI) if ret is not None: ret = Dispatch(ret, 'createNode', '{2933BF80-7B36-11D2-B20E-00C04F983E60}', UnicodeToString=0) return ret @@ -2161,9 +2171,9 @@ return ret # Result is of type IXMLDOMNode - def createNode(self, type=defaultNamedNotOptArg, name=defaultNamedNotOptArg, namespaceURI=defaultNamedNotOptArg): + def createNode(self, Type=defaultNamedNotOptArg, name=defaultNamedNotOptArg, namespaceURI=defaultNamedNotOptArg): """create a node of the specified node type and name""" - ret = self._oleobj_.InvokeTypes(54, LCID, 1, (9, 0), ((12, 1), (8, 1), (8, 1)),type, name, namespaceURI) + ret = self._oleobj_.InvokeTypes(54, LCID, 1, (9, 0), ((12, 1), (8, 1), (8, 1)),Type, name, namespaceURI) if ret is not None: ret = Dispatch(ret, 'createNode', '{2933BF80-7B36-11D2-B20E-00C04F983E60}', UnicodeToString=0) return ret @@ -3058,13 +3068,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -3228,13 +3241,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -3547,13 +3563,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -3628,13 +3647,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -3735,13 +3757,16 @@ return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -4018,13 +4043,16 @@ _prop_map_put_ = { "length": ((65537, LCID, 4, 0),()), } + def __iter__(self): + "Return a Python iterator for this object" + ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) + return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): - import win32com.client.util self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) @@ -4047,7 +4075,7 @@ # Result is a Unicode object - return as-is for this version of Python return self._oleobj_.InvokeTypes(3, LCID, 1, (8, 0), ((8, ,),bstrHeader) - def open(self, bstrMethod=defaultNamedNotOptArg, bstrUrl=defaultNamedNotOptArg, varAsync=defaultNamedOptArg, bstrUser=defaultNamedOptArg, bstrPassword=defaultNamedOptArg): + def Open(self, bstrMethod=defaultNamedNotOptArg, bstrUrl=defaultNamedNotOptArg, varAsync=defaultNamedOptArg, bstrUser=defaultNamedOptArg, bstrPassword=defaultNamedOptArg): """Open HTTP connection""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((8, 1), (8, 1), (12, 17), (12, 17), (12, 17)),bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword) From mhammond at skippinet.com.au Sun Nov 23 21:24:35 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Nov 23 21:34:13 2003 Subject: [python-win32] makepy 0.4.8 != 0.4.6 in build 163 In-Reply-To: Message-ID: <1b4701c3b232$1b0f1cb0$0500a8c0@eden> > I found different behaviour of gencache.EnsureModule in > latest version of > win32com, because generated script differs from previous builds. Yes, this is a bug I guess :( The bug I was fixing is that if a *constant* had a name "None", it would change the value of None etc for the entire program. Breaking scripts that previously had "open" or any other builtin is not good. I'll fix it. Mark. From mhammond at skippinet.com.au Sun Nov 23 21:30:51 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Nov 23 21:34:17 2003 Subject: [python-win32] Path to the service script In-Reply-To: Message-ID: <1b4d01c3b232$fb3354a0$0500a8c0@eden> > I've noticed that the path to the service script is the last > element in > sys.path i.e. sys.path[-1] and not sys.path[0]. > > Is this deliberate and can I rely on this? No, and No :) It should probably be first. Further, in a py2exe built service the only entry on sys.path will be the .zip file. Mark. From mhammond at skippinet.com.au Sun Nov 23 21:48:32 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Nov 23 21:48:41 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? In-Reply-To: <200311071623.54197.mark@hubcapconsulting.com> Message-ID: <1b6901c3b235$73263340$0500a8c0@eden> I'm afraid I can't repro this. I do note however that you may have a possible race: Your main loop does: while self.active: ... rc = win32event.WaitForSingleObject(self.hWaitStop, timeout) and your stop function does: self.active = 0 .. lots of other things, before: win32event.SetEvent(self.hWaitStop) The possibility exists that your main thread could have terminated before the stop thread has got around to setting the event, or doing any of the other work it is doing. However, as I mentioned I can't repro the problem, regardless of how I try. No one else has reported this either. Can you repro it on multiple machines? Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Mark Bucciarelli > Sent: Saturday, 8 November 2003 8:24 AM > To: python-win32@python.org > Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? > > > Stopping the service in the attached script times out (after > a 30 second > delay). The attached example will start/stop properly about > five - eight > times, and hang on the next start/stop cycle. The service > does indeed get > stopped, but Windows displays an error dialog. > > I've boiled it down to a small attached test case, but at > this point I am > stuck. Any suggestions most welcome! > > The attached test_service.py makes the following assumptions: > (1) It assumes Python 22. > (2) It assumes you will run these scripts from c:\temp. > test.py assumes the log file is in c:\temp\test.log. > > To duplicate the behavior, > c:\temp\>test_service.py install > c:\temp\>test_service.py start > c:\temp\>test_service.py stop > ... repeat cycle, quickly and stop will hang > c:\temp\>type test.log > > If you can duplicate the behavior, the log will have a > section similar to the > one I have attached. If you compare the log statements in > test_service.py > with the log output, you can see that that in the > test_service.SimpleService.SvcStop() method, the call to > win32event.SetEvent(self.hWaitStop) never completes. > > Also from the log, you can see that the loop in SvcDoRun does > complete, so the > the hWaitStop event is issued and caught. On a normal > start/stop cycle, the > end of the log looks like this: > > SvcStop 2 > SvcStop 3 > SvcStop complete <-- missing in attached log > SvcDoRun: rc = 0 > SvcDoRun complete > > A more complicated python script I am working on, started in > a similar manner, > times out much more frequently, at least four out of every five stop > attempts. > > I am not subscribed to this list, so please cc me on any > responses. Thanks > for any help! > > Regards, > > -- > Mark Bucciarelli, www.hubcapconsulting.com > As we enjoy great advantages from inventions of others, we should > be glad of an opportunity to serve others by any invention of ours; > and this we should do freely and generously. -- Benjamin Franklin From mark at hubcapconsulting.com Sun Nov 23 22:05:34 2003 From: mark at hubcapconsulting.com (Mark Bucciarelli) Date: Sun Nov 23 22:10:54 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? In-Reply-To: <1b6901c3b235$73263340$0500a8c0@eden> References: <1b6901c3b235$73263340$0500a8c0@eden> Message-ID: <200311232205.34515.mark@hubcapconsulting.com> On Sunday 23 November 2003 9:48 pm, Mark Hammond wrote: > I'm afraid I can't repro this. I was able to reproduce the same behavior with the most simple service script that was posted as an example to win32 list. I'll try to create a more automated test case using this script. > I do note however that you may have a possible race: > > Your main loop does: > > while self.active: > ... > rc = win32event.WaitForSingleObject(self.hWaitStop, timeout) > > and your stop function does: > > self.active = 0 > .. lots of other things, before: > win32event.SetEvent(self.hWaitStop) > > The possibility exists that your main thread could have terminated before > the stop thread has got around to setting the event, or doing any of the > other work it is doing. If I understand you correctly, the main thread will stop and then the stop function will send a message to stop that (now dead) thread. I guess this confuses Windows in a really bad way. (In case you can't tell, I don't know what a thread race is.) I'll double check, but I'm pretty sure the SetEvent is called before the main loop exits, and it (the SetEvent call) never returns. > However, as I mentioned I can't repro the problem, regardless of how I try. > No one else has reported this either. Can you repro it on multiple > machines? Yes. Win 2000 and Win XP. Regards, -- Mark Bucciarelli, www.hubcapconsulting.com GNU/Linux user #266,902 at http://counter.li.org From PYTHON at telefonica.net Mon Nov 24 14:26:30 2003 From: PYTHON at telefonica.net (PYTHON@telefonica.net) Date: Mon Nov 24 14:26:35 2003 Subject: [python-win32] OffTopic (email lib) : attachments in a forwarded email Message-ID: Hi all, Fisrts of all sorry for this off-topic post (I didn?t know where can I post it). I have a problem when I try to get the attachments of a forwarded email; I can only get the attach file that contains the "real attached files I want", not those files # here is my code: import pop3lib impor email.Parser a = poplib.POP3("pop3.telefonica.net") a.user(userpop3) a.pass_(passpop3) try: (numMsgs, totalSize) = a.stat() if numMsgs == 0: print "Sorry - there are no messages in the mailbox" else: for thisNum in range(1, numMsgs + 1): (server_msg, body, octets) = a.retr(thisNum) # "cuerpo" now is a string cuerpo=StringIO.StringIO(string.join(body,'\n')) p = email.Parser.Parser() msg = p.parse(cuerpo) os.chdir(dir_out) for part in msg.walk(): name= part.get_param("name") if name != None: f = open(dir_out + "\\" + name, "wb") f.write(part.get_payload(decode=1)) f.close print "Name of the attachment: ", name a.quit() #thanks From mark at hubcapconsulting.com Mon Nov 24 17:42:22 2003 From: mark at hubcapconsulting.com (Mark Bucciarelli) Date: Mon Nov 24 17:54:53 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? In-Reply-To: <1b6901c3b235$73263340$0500a8c0@eden> References: <1b6901c3b235$73263340$0500a8c0@eden> Message-ID: <200311241742.22716.mark@hubcapconsulting.com> On Sunday 23 November 2003 9:48 pm, Mark Hammond wrote: > I'm afraid I can't repro this. Please try the attached script. It's about as simple a service as you can get. Save script to Lib/site-packages and run it from there. The exception I get (after eight iterations) is: (1053, 'ControlService', 'The service did not respond to the start or control request in a timely fashion') Once I get one error, the exception occurs much earlier; at iteration 2 for example. There was a similar problem reported to this list in July, 2003. I know that the poster, Justin Johnson, has not resolved the problem yet, although he suspects it is related to this issue: http://support.microsoft.com/default.aspx?scid=kb;en-us;812485 I hope this lets you duplicate this behavior. Regards, -- Mark Bucciarelli, www.hubcapconsulting.com GNU/Linux user #266,902 at http://counter.li.org -------------- next part -------------- A non-text attachment was scrubbed... Name: SmallestService.py Type: text/x-python Size: 1742 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20031124/fcf7f235/SmallestService.py From mhammond at skippinet.com.au Mon Nov 24 19:12:19 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Nov 24 19:12:29 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? In-Reply-To: <200311241742.22716.mark@hubcapconsulting.com> Message-ID: <001001c3b2e8$cb193710$0200a8c0@eden> > Please try the attached script. It's about as simple a > service as you can > get. Save script to Lib/site-packages and run it from there. > The exception > I get (after eight iterations) is: > > (1053, 'ControlService', 'The service did not respond to the > start or control > request in a timely fashion') I had a few timing issues with the script as you sent it. I changed the body to: if __name__=='__main__': if len(sys.argv)>1: win32serviceutil.HandleCommandLine(SmallestPythonService) sys.exit(0) # Test from SmallestService import SmallestPythonService n = 5000 servicename = SmallestPythonService._svc_name_ try: win32serviceutil.InstallService(\ win32serviceutil.GetServiceClassString(SmallestPythonService), servicename, SmallestPythonService._svc_display_name_) win32serviceutil.StartService(servicename) time.sleep(1) for i in range(n): print i win32serviceutil.RestartService(servicename) time.sleep(0.5) except: traceback.print_exc() try: win32serviceutil.StopService(servicename) except: print "Couldn't stop service" win32serviceutil.RemoveService(servicename) (win32serviceutil.RestartService should be smarter, so I could not drop all the sleeps). Note I changed the counter to 5000, but I got sick of waiting after 1300 with no problems. I only tried on one machine though. I do note that I know of at least one company who has a fairly widely deployed "shrink-wrap" service using this framework and have never raised this issue with me. I note you added the sleep() in the simple service after reporting the service status. I assume it doesn't fail if you remove this? Can you try specifying a larger "waitHint" param to ReportServiceStatus(), or calling it again directly after the sleep()? Can you reproduce the same error in the "pipe" sample service that comes with win32all? I suspect the issue is simply that Windows is giving up waiting for the service to finish. When it does not finish in a "timely" fashion, it terminates the process. "timely" is defined as what you report to SetServiceStatus. I can't explain how with a default 5 second "wait hint", Windows believes you have timed out, but there is lots I can't explain about Windows > There was a similar problem reported to this list in July, 2003. I know that > the poster, Justin Johnson, has not resolved the problem yet, although he > suspects it is related to this issue: > http://support.microsoft.com/default.aspx?scid=kb;en-us;812485 I can't see how *anything* we do could be related to the issues in that article Mark. From mhammond at skippinet.com.au Tue Nov 25 00:11:54 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Nov 25 00:12:06 2003 Subject: [python-win32] makepy 0.4.8 != 0.4.6 in build 163 In-Reply-To: Message-ID: <004601c3b312$a4d8ca00$0200a8c0@eden> > I found different behaviour of gencache.EnsureModule in > latest version of > win32com, because generated script differs from previous builds. I intend checking in the attached patch, which should fix it. Thanks, Mark. -------------- next part -------------- A non-text attachment was scrubbed... Name: win32com_client.patch Type: application/octet-stream Size: 2240 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20031125/3e167bd3/win32com_client.obj From darkbard at email.it Tue Nov 25 06:50:18 2003 From: darkbard at email.it (darkbard) Date: Tue Nov 25 06:50:22 2003 Subject: [python-win32] accessing GDI from win32all Message-ID: Can I accessi GDI lib from win32all?? From mark at hubcapconsulting.com Tue Nov 25 11:16:44 2003 From: mark at hubcapconsulting.com (Mark Bucciarelli) Date: Tue Nov 25 11:26:27 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? In-Reply-To: <001001c3b2e8$cb193710$0200a8c0@eden> References: <001001c3b2e8$cb193710$0200a8c0@eden> Message-ID: <200311251116.44724.mark@hubcapconsulting.com> On Monday 24 November 2003 7:12 pm, Mark Hammond wrote: > I had a few timing issues with the script as you sent it. Great, so you were able to duplicate the behavior. Two other co-workers also got the same error. > for i in range(n): > print i > win32serviceutil.RestartService(servicename) > time.sleep(0.5) That's wierd. RestartService is basically a Stop then Start. BTW, what version of Python are you running? What's your Windows OS? > I note you added the sleep() in the simple service after reporting the > service status. I assume it doesn't fail if you remove this? Actually, I forgot about that sleep. It was left over from previous testing. I'll see what happens if I take it out. > Can you try specifying a larger "waitHint" param to ReportServiceStatus(), > or calling it again directly after the sleep()? Can you reproduce the same > error in the "pipe" sample service that comes with win32all? Sure, but not until after turkey day. :) > I suspect the issue is simply that Windows is giving up waiting for the > service to finish. When it does not finish in a "timely" fashion, it > terminates the process. "timely" is defined as what you report to > SetServiceStatus. I can't explain how with a default 5 second "wait hint", > Windows believes you have timed out, but there is lots I can't explain > about Windows In the test script, I get a timeout on the on the start, not the stop. I didn't check to see if the service actually was started successfully--if it was, this mirrors the behavior of the stop timeout. Thanks for your help! Regards, -- Mark Bucciarelli, www.hubcapconsulting.com GNU/Linux user #266,902 at http://counter.li.org From theller at python.net Tue Nov 25 12:20:44 2003 From: theller at python.net (Thomas Heller) Date: Tue Nov 25 12:21:04 2003 Subject: [python-win32] Re: accessing GDI from win32all References: Message-ID: "darkbard" writes: > Can I accessi GDI lib from win32all?? Not that I know of, although win32all wraps the MFC (in the win32ui module). If you want to make raw win32 api calls, ctypes would be what you need: Thomas From mhammond at skippinet.com.au Tue Nov 25 16:30:23 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Nov 25 16:30:39 2003 Subject: [python-win32] win32event.SetEvent(self.hWaitStop) hangs? In-Reply-To: <200311251116.44724.mark@hubcapconsulting.com> Message-ID: <00ab01c3b39b$566d43d0$0200a8c0@eden> > On Monday 24 November 2003 7:12 pm, Mark Hammond wrote: > > > I had a few timing issues with the script as you sent it. > > Great, so you were able to duplicate the behavior. Two other > co-workers also > got the same error. No, I could not reproduce the error. The timing issues I saw were errors of the form "The service can not accept the requested control". This will happen if you start the service, but try and stop it while it is still in the "STARTING" state. No bug there. > > > for i in range(n): > > print i > > win32serviceutil.RestartService(servicename) > > time.sleep(0.5) > > That's wierd. RestartService is basically a Stop then Start. Along with waiting for the status to change to a known value - and this is where that function is "dumb". It assumes the service is already in a "started" state, not handling the fact that it may still be transitioning to that state. It *does* allow for the transition from running to stopped though, so it can correctly send a start message without that "unable to accept the control" message. > BTW, what version of Python are you running? What's your Windows OS? 2k, 2.3 > In the test script, I get a timeout on the on the start, not > the stop. I > didn't check to see if the service actually was started > successfully--if it > was, this mirrors the behavior of the stop timeout. As above, they are completely different issues. Mark. From shamsul at handisplay.com.my Fri Nov 28 07:08:52 2003 From: shamsul at handisplay.com.my (Shamsul Azhar) Date: Fri Nov 28 07:09:06 2003 Subject: [python-win32] GetClipboardData crashes Python Message-ID: Hi, I'm trying to manipulate a bitmap data from within Python, however Python crashed when using "GetClipboardData". Is there any way of getting bitmap data from the clipboard? The following is what I did :- >>> from win32clipboard import * >>> OpenClipboard() >>> IsClipboardFormatAvailable(CF_DIB) 1 >>> GetClipboardData(CF_DIB) Thanks in advanced. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031128/794f864c/attachment.html From pascor at hotpop.com Fri Nov 28 22:06:52 2003 From: pascor at hotpop.com (Ray Pasco) Date: Fri Nov 28 22:07:10 2003 Subject: [python-win32] Win32 Mode Message-ID: <3FC80D4C.5050508@hotpop.com> How can a script be "put in" Win32 mode in order to use some of the win32api calls ? From mhammond at skippinet.com.au Fri Nov 28 22:54:27 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Nov 28 22:54:38 2003 Subject: [python-win32] Win32 Mode In-Reply-To: <3FC80D4C.5050508@hotpop.com> Message-ID: <001001c3b62c$7da3d110$0200a8c0@eden> It doesn't - you just import the modules, and away you go. If the modules aren't installed, you get an ImportError you can handle any way you like. Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Ray Pasco > Sent: Saturday, 29 November 2003 2:07 PM > To: python-win32@python.org > Subject: [python-win32] Win32 Mode > > > How can a script be "put in" Win32 mode in order to use some of the > win32api calls ? From mhammond at skippinet.com.au Sat Nov 29 00:53:08 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat Nov 29 00:53:19 2003 Subject: [python-win32] GetClipboardData crashes Python In-Reply-To: Message-ID: <002d01c3b63d$1178de20$0200a8c0@eden> I'm afraid you struck a bug with the crash - what it is supposed to do is return a NotImplementedError exception, so it wouldn't have really helped. I have just added a new win32clipboard.GetClipboardDataHandle() function, which always returns an integer handle, and also fixed the crash with CF_DIB. I'd like to add support for getting the binary data of the other clipboard formats, but I need someone who understands it alittle and is willing to test for me. Mark. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Shamsul Azhar Sent: Friday, 28 November 2003 11:09 PM To: python-win32@python.org Subject: [python-win32] GetClipboardData crashes Python Hi, I'm trying to manipulate a bitmap data from within Python, however Python crashed when using "GetClipboardData". Is there any way of getting bitmap data from the clipboard? The following is what I did :- >>> from win32clipboard import * >>> OpenClipboard() >>> IsClipboardFormatAvailable(CF_DIB) 1 >>> GetClipboardData(CF_DIB) Thanks in advanced. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031129/8d74edfb/attachment.html From guy at r-e-d.co.nz Sat Nov 29 03:41:00 2003 From: guy at r-e-d.co.nz (Guy Robinson) Date: Sat Nov 29 03:40:03 2003 Subject: [python-win32] win32print Message-ID: <3FC85B9C.1050900@r-e-d.co.nz> Hello, I've got this working print queue montior and currently it checks the queues every 1 second. I'm worried that I might miss events if I set in to more than this. Particularly as I would like to perform functions depending on status codes. When I don't have a delay in the CPU usage is huge 70%. My question is, is there an 'intelligient' way of monitoring the spooler? I guess what I'm thinking is some low cpu method of watching for activity on the spooler, and triggering my program as the spooler stops and starts. Suggestions? Regards, Guy Here's my code so far: try: import win32print except: print 'win32all required .' import time #constants wp = win32print # lists and dicitonaries of constants ptypelist = [(wp.PRINTER_ENUM_SHARED,'shared'),(wp.PRINTER_ENUM_LOCAL,'local'),(wp.PRINTER_ENUM_CONNECTIONS,'network')] cmds = {'Pause':wp.JOB_CONTROL_PAUSE, 'cancel':wp.JOB_CONTROL_CANCEL, 'resume':wp.JOB_CONTROL_RESUME, 'prior_low':wp.MIN_PRIORITY,'prior_high':wp.MAX_PRIORITY,'prior_normal':wp.DEF_PRIORITY } statuscodes = {'deleting':wp.JOB_STATUS_DELETING,'error':wp.JOB_STATUS_ERROR,'offline':wp.JOB_STATUS_OFFLINE,'paper out':wp.JOB_STATUS_PAPEROUT,'paused':wp.JOB_STATUS_PAUSED,'printed':wp.JOB_STATUS_PRINTED,'printing':wp.JOB_STATUS_PRINTING,'spooling':wp.JOB_STATUS_SPOOLING} class PMFuncs: def __init__(self): # initialise the list of printers self.PList =[] def PrinterList(self): # returns a list of dicts. # this gets the default printer tmpdic ={} DefPName = win32print.GetDefaultPrinter() # Get the default printer firstso we can add this to the list of printers for pt in ptypelist: try: for (Flags,pDescription,pName,pComment) in list(win32print.EnumPrinters(pt[0],None,1)): tmpdic ={} tmpdic['PType'] = pt[1] tmpdic['Flags'] = Flags tmpdic['Description'] = pDescription #test for if this is the default printer if pName == DefPName: tmpdic['DefPrinter':True] else: tmpdic['DefPrinter':False] tmpdic['Name'] = pName tmpdic['Comment'] = pComment self.PList.append(tmpdic) except: pass #no printers of this type so don't add anything return self.PList #list of installed printers def GetJobList(self,printer): phandle = win32print.OpenPrinter(printer) #now get all the print jobs (start at job 0 and -1 for all jobs) jlist = win32print.EnumJobs(phandle,0,-1,1) win32print.ClosePrinter(phandle) return jlist # this lists all jobs on all printers def GetJobInfo(self,printer,jobID): phandle = win32print.OpenPrinter(printer) ilist = win32print.GetJob(phandle,jobID,1) win32print.ClosePrinter(phandle) return ilist #this lists all info available at level 1 for selected job. def SetJobCmd(self, printer, jobID , JobInfo , RCmd ): phandle = win32print.OpenPrinter(printer) win32print.SetJob(phandle,jobID,1,JobInfo,Cmds[RCmd]) win32print.ClosePrinter(phandle) # test functions e = PMFuncs() while 1: time.sleep(1) e = PMFuncs() for i in e.PrinterList(): try: p = e.GetJobList(i['Name']) for w in p: print e.GetJobInfo(i['Name'],w['JobID']) except: pass From pascor at hotpop.com Sat Nov 29 07:55:05 2003 From: pascor at hotpop.com (Ray Pasco) Date: Sat Nov 29 07:55:52 2003 Subject: [python-win32] Win32 Mode References: <001001c3b62c$7da3d110$0200a8c0@eden> Message-ID: <3FC89729.2010908@hotpop.com> That's not what seems to be happening. Here's the entire code: import win32api win32api.InitiateSystemShutdown ('', '', 0, 1, 1) and this is the result: Traceback (most recent call last): File "try.py", line 9, in ? win32api.InitiateSystemShutdown ('', '', 0, 1, 1) pywintypes.error: (120, 'InitiateSystemShutdown', 'This function is only valid in Win32 mode.') Hmmmm... Mark Hammond wrote: >It doesn't - you just import the modules, and away you go. If the modules >aren't installed, you get an ImportError you can handle any way you like. > >Mark. > > > >>-----Original Message----- >>From: python-win32-bounces@python.org >>[mailto:python-win32-bounces@python.org]On Behalf Of Ray Pasco >>Sent: Saturday, 29 November 2003 2:07 PM >>To: python-win32@python.org >>Subject: [python-win32] Win32 Mode >> >> >>How can a script be "put in" Win32 mode in order to use some of the >>win32api calls ? >> >> > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031129/ce199b33/attachment.html From hameedkhaan at yahoo.com Sat Nov 29 16:30:13 2003 From: hameedkhaan at yahoo.com (Hameed Khan) Date: Sat Nov 29 16:30:37 2003 Subject: [python-win32] python win32 books Message-ID: <20031129213013.8976.qmail@web20412.mail.yahoo.com> Hello all, are there good books for python win32 platform. if there is any then please tell me the name. i really need a book. Thanks, Khaan ===== _____________________ Hameed Ullah Khan *Try not to become a man of success but rather to become a man of value.* Albert Einstein __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ From kojo at hal-pc.org Sat Nov 29 18:08:37 2003 From: kojo at hal-pc.org (Kojo Idrissa) Date: Sat Nov 29 18:08:41 2003 Subject: [python-win32] python win32 books In-Reply-To: <20031129213013.8976.qmail@web20412.mail.yahoo.com> Message-ID: "Python Programming on Win 32" is the only one I know of with that SPECIFIC focus. There may be others, but I don't know of them. On Sat, 29 Nov 2003 13:30:13 -0800 (PST) Hameed Khan wrote: ]Hello all, ] are there good books for python win32 platform. ]if there is any then please tell me the name. i really ]need a book. ]Thanks, ]Khaan **************************** Kojo Idrissa kojo@hal-pc.org http://www.hal-pc.org/~kojo **************************** From mhammond at skippinet.com.au Sun Nov 30 05:06:19 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Nov 30 05:06:32 2003 Subject: [python-win32] Win32 Mode In-Reply-To: <3FC89729.2010908@hotpop.com> Message-ID: <018901c3b729$9a0b9ba0$0200a8c0@eden> My guess is you are running Win9x - these functions only exist in the NT family (NT/2k/xp). The MSDN docs document what functions can be used where, and I haven't tried to mirror that in the PyWin32 docs. Do a google search for how to shutdown 9x - IIRC, it is simply a matter of sending explorer a message. (Initially, avoid 'python' in your search - it may still give you the clue) Mark. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Ray Pasco Sent: Saturday, 29 November 2003 11:55 PM To: Python-win32@python.org Subject: Re: [python-win32] Win32 Mode That's not what seems to be happening. Here's the entire code: import win32api win32api.InitiateSystemShutdown ('', '', 0, 1, 1) and this is the result: Traceback (most recent call last): File "try.py", line 9, in ? win32api.InitiateSystemShutdown ('', '', 0, 1, 1) pywintypes.error: (120, 'InitiateSystemShutdown', 'This function is only valid in Win32 mode.') Hmmmm... Mark Hammond wrote: It doesn't - you just import the modules, and away you go. If the modules aren't installed, you get an ImportError you can handle any way you like. Mark. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Ray Pasco Sent: Saturday, 29 November 2003 2:07 PM To: python-win32@python.org Subject: [python-win32] Win32 Mode How can a script be "put in" Win32 mode in order to use some of the win32api calls ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031130/0196e92a/attachment.html From hameedkhaan at yahoo.com Sun Nov 30 12:30:27 2003 From: hameedkhaan at yahoo.com (Hameed Khan) Date: Sun Nov 30 12:30:57 2003 Subject: [python-win32] help about thread programming Message-ID: <20031130173027.4586.qmail@web20411.mail.yahoo.com> Hi, i try to consult python documentation for thread and threading module. i look at few scripts. but didn't get any idea of threading. i am really fedup of it now. and i dont want to give up. i will try to search on google. but if any one of you can write a simple threading script with explanation then it will be very valuable for me. and i will try to learn from it. waiting for your replies and advices. Thanks, Hameed Khan __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ From forestiero at qwest.net Sun Nov 30 12:48:10 2003 From: forestiero at qwest.net (DogWalker) Date: Sun Nov 30 12:48:22 2003 Subject: [python-win32] Win32 Mode References: <018901c3b729$9a0b9ba0$0200a8c0@eden> Message-ID: <037501c3b76a$20ac8760$2ba50043@presario> It looks like Win9x should use ExitWindowsEx function. ----- Original Message ----- From: Mark Hammond To: pascor@hotpop.com ; Sent: Sunday, November 30, 2003 2:06 AM Subject: RE: [python-win32] Win32 Mode My guess is you are running Win9x - these functions only exist in the NT family (NT/2k/xp). The MSDN docs document what functions can be used where, and I haven't tried to mirror that in the PyWin32 docs. Do a google search for how to shutdown 9x - IIRC, it is simply a matter of sending explorer a message. (Initially, avoid 'python' in your search - it may still give you the clue) Mark. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Ray Pasco Sent: Saturday, 29 November 2003 11:55 PM To: Python-win32@python.org Subject: Re: [python-win32] Win32 Mode That's not what seems to be happening. Here's the entire code: import win32api win32api.InitiateSystemShutdown ('', '', 0, 1, 1) and this is the result: Traceback (most recent call last): File "try.py", line 9, in ? win32api.InitiateSystemShutdown ('', '', 0, 1, 1) pywintypes.error: (120, 'InitiateSystemShutdown', 'This function is only valid in Win32 mode.') Hmmmm... Mark Hammond wrote: It doesn't - you just import the modules, and away you go. If the modules aren't installed, you get an ImportError you can handle any way you like. Mark. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Ray Pasco Sent: Saturday, 29 November 2003 2:07 PM To: python-win32@python.org Subject: [python-win32] Win32 Mode How can a script be "put in" Win32 mode in order to use some of the win32api calls ? ---------------------------------------------------------------------------- -- _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20031130/399107bf/attachment.html From chandrakant.deshmukh at teleatlas.com Fri Nov 28 01:56:02 2003 From: chandrakant.deshmukh at teleatlas.com (Chandrakant Deshmukh) Date: Sun Nov 30 21:04:30 2003 Subject: [python-win32] How to upload multiple files from win32 to linux using TOMCAT. Message-ID: <3FC6F182.A9A0C6CD@teleatlas.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: chandrakant.deshmukh.vcf Type: text/x-vcard Size: 252 bytes Desc: Card for Chandrakant deshmukh Url : http://mail.python.org/pipermail/python-win32/attachments/20031128/652ed1b9/chandrakant.deshmukh.vcf