From glc at well.com Thu Jan 1 14:27:22 2004 From: glc at well.com (Greg Chapman) Date: Thu Jan 1 15:00:14 2004 Subject: [python-win32] Damaged Pythonwin installation Message-ID: I seem to have done something which has broken Pythonwin on one of my machines. It's using win32all build 163 and Python 2.3.2 (the OS is Windows 2000). The most immediate symptom is that things seem very sluggish inside Pythonwin. However there are other more spectacular problems. For example, I just started Pythonwin, created a new script document with the line "print 'hello'", and saved it as temp.py. I then pressed F11 twice. This first loads the debugger (very slowly) and then results in these error messages in the interactive window when the debugger attempts to step into winout.py: LoadBarState failed - LoadBarState failed (with win32 exception!) < snip traceback > win32ui: LoadFrame failed win32ui: CreateNewFrame() virtual handler (>) raised an exception TypeError: PyCTemplate::CreateNewFrame must return a PyCFrameWnd object. Whatever the error was, it had some global effects. After the error, my Windows Start Menu was hosed (it only had the four items which are normally above the top separator). Also, notepad.exe started after the error comes up without a menu bar. Everything is back to normal after a reboot. In case it's important, I had a newer version of scintilla.dll than the one which comes with Pythonwin in a directory on the system PATH (but not in python's sys.path). Several reboots ago I renamed the dll in case Pythonwin was somehow finding it instead of its own version, but that didn't seem to make any difference. I've already tried uninstalling and reinstalling win32all; unfortunately, that did not fix the problem. Anybody have any ideas on what's gone wrong here? Thanks. --- Greg Chapman From geoff at jonas.ns.ca Fri Jan 2 13:32:14 2004 From: geoff at jonas.ns.ca (Geoff Skerrett) Date: Fri Jan 2 13:33:36 2004 Subject: [python-win32] Retrieving Value from Child window Edit Controls Message-ID: <000401c3d15e$be3c74f0$3300a8c0@jonas.ns.ca> I am hoping someone can assist me with a Win32api problem. We would like to build an application that will allow us to monitor another program running on the same computer. The target pacakge is not "COM" aware, so I think/hope I can use the Win32api to read the values directly from the edit controls. The target applications is for "accounting" so there is alot of edit control on the screen. Using win32gui.FindWindow and then EnumChildWindows I can retrieve the handles, titles and names of all the child windows that are open, however, I can't seem to see any of the "edit" controls. Is this possible to do this with python, and if so I would appreciate it if someone could point me in the right direction. Geoff. From glc at well.com Sat Jan 3 17:17:57 2004 From: glc at well.com (Greg Chapman) Date: Sat Jan 3 17:18:07 2004 Subject: [python-win32] Damaged Pythonwin installation -- resolved(?) Message-ID: In case anyone's interested, it appears I have fixed the problem described in my earlier message. Looking at the Python for Win32 folder in the registry, I found hundreds of ToolbarDebugging and ToolbarDefault entries. So I uninstalled again, deleted all the win32all registry entries I could find, and then reinstalled. So far, things seem to be working correctly. If anyone knows, I'm still curious to find out how this situation happened, in case all I've done is fix a symptom. --- Greg Chapman From robin at reportlab.com Sat Jan 3 17:47:09 2004 From: robin at reportlab.com (Robin Becker) Date: Sat Jan 3 17:48:56 2004 Subject: [python-win32] Damaged Pythonwin installation -- resolved(?) In-Reply-To: References: Message-ID: In article , Greg Chapman writes >In case anyone's interested, it appears I have fixed the problem described >in my earlier message. Looking at the Python for Win32 folder in the >registry, I found hundreds of ToolbarDebugging and ToolbarDefault entries. >So I uninstalled again, deleted all the win32all registry entries I could >find, and then reinstalled. So far, things seem to be working correctly. > >If anyone knows, I'm still curious to find out how this situation happened, >in case all I've done is fix a symptom. > >--- >Greg Chapman I had a similar problem. I think it came about when stopping a debug run using the tray icon, but am not absolutely certain. Looking in my current registry I see 8 of each. -- Robin Becker From tim.golden at viacom-outdoor.co.uk Mon Jan 5 04:13:39 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Jan 5 04:21:26 2004 Subject: [python-win32] Retrieving Value from Child window Edit Contro ls Message-ID: >From: Geoff Skerrett [mailto:geoff@jonas.ns.ca] > We would like to build an application that will allow us to > monitor another program running on the same computer. >Is this possible to do this with python, and if so I would >appreciate it if >someone could point me in the right direction. > >Geoff. You may already have seen this, but in case you haven't, have a look... http://www.brunningonline.net/simon/blog/archives/000664.html TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Frank.Lindseth at sintef.no Mon Jan 5 20:29:08 2004 From: Frank.Lindseth at sintef.no (Frank Lindseth) Date: Tue Jan 6 00:43:10 2004 Subject: [python-win32] problems integrating ultrasound (.exe server + ActiveX Control) in client application using win32com Message-ID: <002001c3d3f4$7b50a6f0$4127fea9@TeleRad> Hi, I am trying to integrate medical ultrasound in a image guided surgery application using win32com. The client application is supposed to initialize the streaming video mechanism by calling methods on the IDocumentDisp COM interface of Ultrasound.exe (us below) which creates a shared-memory queue. TTFrameReceiver (an ActiveX control, fr below ) encapsulates access to the shared-memory queue and named event synchronization mechanism. Unfortunately the fr (fr.Open(u'TTSample')) is not able to connect to the shared-memory queue (see python session below). Can anybody see what the problem is, or tell me how to proceed ? Is there something wrong with the parameter passing (se SDK doc and makepy generated functions at the end)? (I'm new to win32com, and these magic numbers in the call to InvokeTypes is a mystery..., where are they defined? is there a short description of the concept somewhere? ) Any suggestions would be greatly appreciated. Thanks, Frank Lindseth ---------- ----- Some lines from a simple test client in C++ that works: // Open the shared-memory frame stream on the Ultrasound server // with the name TTSample, 3 frame buffers, each 500000 bytes max., // in "LIO" mode (other possibilities "FIFO" and "LIFO"), // and with overwrite permission to overwrite oldest m_TTAutomate.OpenFrameStream(_T("TTSample"), 3, 500000, "LIO", 1); // Open the frame receiver m_TTFrameRx.Open(_T("TTSample")); // Start transmitting images m_TTAutomate.StartTransmitting(); ----- Python session: PythonWin 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> from win32com.client import gencache, Dispatch >>> usm = gencache.EnsureModule('{B5FFEB70-CFCA-4F59-9522-0281C2D2CC84}', 0, 3, 3) >>> d = Dispatch("Ultrasound.Document") >>> us = usm.IDocumentDisp(d) >>> us >>> frm = gencache.EnsureModule('{F806CFFE-E637-452B-AA80-264E62E68361}', 0, 1, 0) >>> fr = Dispatch("TTFRAMERECEIVER.TTFrameReceiverCtrl.1") >>> fr >>> us.InitTT2000() >>> us.VersionString() u'Terason Model 2000 Imaging System Version: 3.3.1 (RELEASE-Build 1456)' >>> us.ShowWindow(0, -1,-1,-1,-1, 0) >>> us.GetDepth() 150 >>> us.SetDepth(100) >>> us.GetMap() u'E' >>> us.SetMap(u'F') u'F' >>> us.OpenFrameStream(u'TTSample', 3, 500000, u'LIO', 1) (u'TTSample', u'LIO') >>> fr.Open(u'TTSample') >>> fr.Open(u'TTSample') Traceback (most recent call last): File "", line 1, in ? File "win32com\gen_py\F806CFFE-E637-452B-AA80-264E62E68361x0x1x0.py", line 91, in Open com_error: (-2147418113, 'Alvorlig feil', None, None) >>> ( -------And the rest of the sequence would normally be: us.StartTransmitting() ------ receive COM events.... us.StopTransmitting() fr.Close() us.CloseFrameStream() us.ShowWindow(0, -1,-1,-1,-1, 1) ) -------- COM ref. And makepy output: ---- Ultrasound COM automation interface [id(18)] void SetMap(BSTR* name); [id(29)] void OpenFrameStream(BSTR* queueName, short numBuffers, long bufferSize, BSTR* queueOrder, short overwritePermission); def SetMap(self, name=defaultNamedNotOptArg): """method SetMap - Set the imaging map""" return self._oleobj_.InvokeTypes(18, LCID, 1, (24, 0), ((16392, 0),),name) def OpenFrameStream(self, queueName=defaultNamedNotOptArg, numBuffers=defaultNamedNotOptArg, bufferSize=defaultNamedNotOptArg, queueOrder=defaultNamedNotOptArg, overwritePermission=defaultNamedNotOptArg): """method OpenFrameStream - Open shared-memory streaming frame interface""" return self._oleobj_.InvokeTypes(29, LCID, 1, (24, 0), ((16392, 0), (2, 0), (3, 0), (16392, 0), (2, 0)),queueName, numBuffers, bufferSize, queueOrder, overwritePermission) --- TTFrameReceiver ActiveX Control [id(1)] boolean Open(BSTR name); def Open(self, name=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(1, LCID, 1, (11, 0), ((8, 0),),name) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040106/875d3602/attachment-0001.html From Frank.Lindseth at sintef.no Tue Jan 6 06:05:12 2004 From: Frank.Lindseth at sintef.no (Frank Lindseth) Date: Tue Jan 6 06:05:17 2004 Subject: [python-win32] Re: problems integrating ultrasound (.exe server + ActiveX Control) Message-ID: <33061239-4038-11D8-8117-000A95864E24@sintef.no> Hi, A short correction to my previous mail (one fr.Open to much): It should be: >>> us.OpenFrameStream(u'TTSample', 3, 500000, u'LIO', 1) (u'TTSample', u'LIO') >>> fr.Open(u'TTSample') Traceback (most recent call last): File "", line 1, in ? File "win32com\gen_py\F806CFFE-E637-452B-AA80-264E62E68361x0x1x0.py", line 91, in Open com_error: (-2147418113, 'Alvorlig feil', None, None) >>> Instead of: >>> us.OpenFrameStream(u'TTSample', 3, 500000, u'LIO', 1) (u'TTSample', u'LIO') >>> fr.Open(u'TTSample') >>> fr.Open(u'TTSample') Traceback (most recent call last): File "", line 1, in ? File "win32com\gen_py\F806CFFE-E637-452B-AA80-264E62E68361x0x1x0.py", line 91, in Open com_error: (-2147418113, 'Alvorlig feil', None, None) >>> And 'Alvorlig feil' means a serious error... Any ideas on what's going wrong is greatly appreciated. Thanks, Frank Lindseth -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 1190 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20040106/91a78845/attachment.bin From jens.jorgensen at tallan.com Tue Jan 6 10:37:37 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Jan 6 10:38:26 2004 Subject: [python-win32] problems integrating ultrasound (.exe server + ActiveX Control) in client application using win32com In-Reply-To: <002001c3d3f4$7b50a6f0$4127fea9@TeleRad> References: <002001c3d3f4$7b50a6f0$4127fea9@TeleRad> Message-ID: <3FFAD641.3020503@tallan.com> Just a guess here Frank but if fr is an ActiveX Control then might it not need to be created within the context of a valid ActiveX Container Application? I'm sure there's a way to do this with the win32all packages but I don't mess with the GUI stuff contained in win32all so I wouln't be able to venture a guess myself. I'll bet there's example code in there somewhere though. Frank Lindseth wrote: > Hi, > > > > I am trying to integrate medical ultrasound in a image guided surgery > application using win32com. > > The client application is supposed to initialize the streaming video > mechanism by calling methods on the > > IDocumentDisp COM interface of Ultrasound.exe (us below) which > creates a shared-memory queue. > > TTFrameReceiver (an ActiveX control, fr below ) encapsulates access to > the shared-memory queue and named event synchronization mechanism. > Unfortunately the fr (fr.Open(u'TTSample')) is not able to connect to > the shared-memory queue (see python session below). > > > > Can anybody see what the problem is, or tell me how to proceed ? > > Is there something wrong with the parameter passing (se SDK doc and > makepy generated functions at the end)? > > (I'm new to win32com, and these magic numbers in the call to > InvokeTypes is a mystery..., > > where are they defined? is there a short description of the concept > somewhere? ) > > > > Any suggestions would be greatly appreciated. > > > > Thanks, > > Frank Lindseth > > > > ---------- > > ----- Some lines from a simple test client in C++ that works: > > // Open the shared-memory frame stream on the Ultrasound server > > // with the name TTSample, 3 frame buffers, each 500000 bytes max., > > // in "LIO" mode (other possibilities "FIFO" and "LIFO"), > > // and with overwrite permission to overwrite oldest > > m_TTAutomate.OpenFrameStream(_T("TTSample"), 3, 500000, "LIO", 1); > > > > // Open the frame receiver > > m_TTFrameRx.Open(_T("TTSample")); > > > > // Start transmitting images > > m_TTAutomate.StartTransmitting(); > > > > > > ----- Python session: > > PythonWin 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit > (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond > (mhammond@skippinet.com.au) - see 'Help/About PythonWin' for further > copyright information. > >>>> from win32com.client import gencache, Dispatch > >>>> usm = > > gencache.EnsureModule('{B5FFEB70-CFCA-4F59-9522-0281C2D2CC84}', 0, 3, 3) > >>>> d = Dispatch("Ultrasound.Document") > >>>> us = usm.IDocumentDisp(d) > >>>> us > > at 0x19204776> > >>>> frm = > > gencache.EnsureModule('{F806CFFE-E637-452B-AA80-264E62E68361}', 0, 1, 0) > >>>> fr = Dispatch("TTFRAMERECEIVER.TTFrameReceiverCtrl.1") > >>>> fr > > module._DTTFrameReceiver instance at 0x19269592> > >>>> us.InitTT2000() > >>>> us.VersionString() > > u'Terason Model 2000 Imaging System Version: 3.3.1 (RELEASE-Build 1456)' > >>>> us.ShowWindow(0, -1,-1,-1,-1, 0) > >>>> us.GetDepth() > > 150 > >>>> us.SetDepth(100) > >>>> us.GetMap() > > u'E' > >>>> us.SetMap(u'F') > > u'F' > >>>> us.OpenFrameStream(u'TTSample', 3, 500000, u'LIO', 1) > > (u'TTSample', u'LIO') > >>>> fr.Open(u'TTSample') > >>>> fr.Open(u'TTSample') > > Traceback (most recent call last): > > File "", line 1, in ? > > File "win32com\gen_py\F806CFFE-E637-452B-AA80-264E62E68361x0x1x0.py", > > line 91, in Open > > com_error: (-2147418113, 'Alvorlig feil', None, None) > >>>> > > ( > > -------And the rest of the sequence would normally be: > > us.StartTransmitting() > > ------ receive COM events.... > > us.StopTransmitting() > > fr.Close() > > us.CloseFrameStream() > > us.ShowWindow(0, -1,-1,-1,-1, 1) > > ) > > > > > > -------- COM ref. And makepy output: > > ---- Ultrasound COM automation interface > > [id(18)] void SetMap(BSTR* name); > > [id(29)] void OpenFrameStream(BSTR* queueName, short numBuffers, long > bufferSize, BSTR* queueOrder, short overwritePermission); > > > > def SetMap(self, name=defaultNamedNotOptArg): > > """method SetMap - Set the imaging map""" > > return self._oleobj_.InvokeTypes(18, LCID, 1, > (24, 0), ((16392, 0),),name) > > def OpenFrameStream(self, queueName=defaultNamedNotOptArg, > numBuffers=defaultNamedNotOptArg, bufferSize=defaultNamedNotOptArg, > queueOrder=defaultNamedNotOptArg, > > overwritePermission=defaultNamedNotOptArg): > > """method OpenFrameStream - Open shared-memory > streaming frame interface""" > > return self._oleobj_.InvokeTypes(29, LCID, 1, > (24, 0), ((16392, 0), (2, 0), (3, 0), (16392, 0), (2, 0)),queueName, > numBuffers, bufferSize, queueOrder, overwritePermission) > > > > --- TTFrameReceiver ActiveX Control > > [id(1)] boolean Open(BSTR name); > > > > def Open(self, name=defaultNamedNotOptArg): > > return self._oleobj_.InvokeTypes(1, LCID, 1, > (11, 0), ((8, 0),),name) > > > > > > > > > > > >------------------------------------------------------------------------ > >_______________________________________________ >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 geek at cfl.rr.com Wed Jan 7 18:57:11 2004 From: geek at cfl.rr.com (Steven M. Faulconer) Date: Wed Jan 7 18:57:21 2004 Subject: [python-win32] Window Location & Logout Message-ID: <3FFC9CD7.4020000@cfl.rr.com> Hello Everyone, I've only been using Python for a short time, but I've enjoyed what I've done with it so far. I've written a login script for our systems that do various tasks, some of them are interactive. It works very well, except when the script runs at logon, the window is minimized. Is there a programatic way to tell the window to 'unminimize' itself? Also, is there a programatic (through win32api or com) to tell a system to logout? Specifics: Python 2.3.3 Win32all 163 Windows 2000 Thanks! Steven Faulconer From tim.golden at viacom-outdoor.co.uk Thu Jan 8 03:55:52 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jan 8 04:12:16 2004 Subject: [python-win32] Window Location & Logout Message-ID: >-----Original Message----- >From: Steven M. Faulconer [mailto:geek@cfl.rr.com] > > I've written a login script for our systems that do > various tasks, some of them are interactive. First of all, a warning. If you're talking here about the logon to an NT domain and its corresponding logon script, be aware that some slightly unexpected things can happen because there's no guarantee of what is and what isn't set up while the script is running. This warning is very vague and woolly, but is down to my own moderate experience at getting NT logon scripts running with and without Python. If you're talking about some other kind of logon, eg to an application, then ignore that last paragraph. Well, don't ignore it completely; it might come in useful some day! > It works very well, except when the script runs at logon, > the window is minimized. Is there a programatic way to tell > the window to 'unminimize' itself? Can you be more specific? Which bit is calling which bit and how? Which window is minimized? etc. I can't quite get a clear picture of what's happening. > Also, is there a programatic (through win32api or com) to tell > a system to logout? OK; here I can help. If you want to do *any* work on Python/Win32, I *strongly* recommend Mark Hammond / Andy Robinson's book on the subject: Python Programming on Win32: [http://www.oreilly.com/catalog/pythonwin32/] You can get to it via O'Reilly's Safari, which I also recommend: [http://safari.oreilly.com/1565926218] In Chapter 16, on page 305 in my edition, there's a description of how to reboot a machine, which uses the win32api.InitiateSystemShutdown function. I think it's already been discussed on this list; check the archives: http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/Python-win32 or http://mail.python.org/pipermail/python-win32/ I don't have any experience myself of that particular approach, so I'll leave others to follow up on that. What I do have experience of is WMI. As you're using W2000, you've got everything you need, so try the following: 1) Download and install the WMI module from here: http://tgolden.sc.sabren.com/python/wmi.html 2) Check out the similar example here: http://tgolden.sc.sabren.com/python/wmi_cookbook.html#reboot_remote_machine 3) Try the following code: import wmi c = wmi.WMI (privileges=["Shutdown"]) for os in c.Win32_OperatingSystem (): os.Win32Shutdown (Flags=0) Flags=0 is a logoff. The Win32Shutdown method is documented on MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/ win32shutdown_method_in_class_win32_operatingsystem.asp HTH TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From theller at python.net Thu Jan 8 04:22:53 2004 From: theller at python.net (Thomas Heller) Date: Thu Jan 8 04:23:04 2004 Subject: [python-win32] Re: Window Location & Logout References: <3FFC9CD7.4020000@cfl.rr.com> Message-ID: "Steven M. Faulconer" writes: > Hello Everyone, > > I've only been using Python for a short time, but I've enjoyed what > I've done with it so far. I've written a login script for our systems > that do various tasks, some of them are interactive. It works very > well, except when the script runs at logon, the window is > minimized. Is there a programatic way to tell the window to > 'unminimize' itself? A random idea, don't know if this works: there's a win32 GetConsoleWindow() function which returns the console's window handle. You could try to call this, and then send messages to the window (if the functions you need are not wrapped by win32all, try ctypes). Thomas From tim.golden at viacom-outdoor.co.uk Thu Jan 8 07:35:11 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jan 8 07:43:05 2004 Subject: [python-win32] Window Location & Logout Message-ID: >From: Steven Faulconer [mailto:sfaulconer@cfl.rr.com] > >When the >script is run as a login, the same thing happens, but that console >window is minimized, which is normal for login scripts. My >desire is to >have my script force its window to be normal sized (not-minimized). If you can control the way in which your logon process launches the py script, then you should be able to specify non-minimized as a window creation style. If you don't have that much control, I can only second Thomas Heller's suggestion earlier that you use ctypes to obtain the handle of the script's console window and send it whatever message Win32 uses to request maximise. (hint: sometimes, using a shortcut can help here, since the shortcut can specify the window characteristics) TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From sfaulconer at cfl.rr.com Thu Jan 8 07:12:31 2004 From: sfaulconer at cfl.rr.com (Steven Faulconer) Date: Thu Jan 8 10:29:23 2004 Subject: [python-win32] Window Location & Logout In-Reply-To: References: Message-ID: <3FFD492F.5000204@cfl.rr.com> Tim, Thanks for the response. The logon scripts are actually local to the system, no domain controllers involved, but I'll keep your warning in mind. And I plan to purchase the Python Win32 book today. What is happening is the script is not graphical, but it is interactive, so when you execute it (standalone, non-login) a console window appears running python.exe, since the .py files are all associated with python. When the script is run as a login, the same thing happens, but that console window is minimized, which is normal for login scripts. My desire is to have my script force its window to be normal sized (not-minimized). And thank you for the pointers on the logoff, I'll take a look at WMI. Thanks again for the response. Steven Faulconer Tim Golden wrote: >>-----Original Message----- >>From: Steven M. Faulconer [mailto:geek@cfl.rr.com] >> >>I've written a login script for our systems that do >>various tasks, some of them are interactive. >> >> > >First of all, a warning. If you're talking here about >the logon to an NT domain and its corresponding logon >script, be aware that some slightly unexpected things >can happen because there's no guarantee of what is and >what isn't set up while the script is running. This >warning is very vague and woolly, but is down to my own >moderate experience at getting NT logon scripts running >with and without Python. > >If you're talking about some other kind of logon, eg to >an application, then ignore that last paragraph. Well, >don't ignore it completely; it might come in useful some day! > > > >>It works very well, except when the script runs at logon, >>the window is minimized. Is there a programatic way to tell >>the window to 'unminimize' itself? >> >> > >Can you be more specific? Which bit is calling which bit and >how? Which window is minimized? etc. I can't quite get a clear >picture of what's happening. > > > >>Also, is there a programatic (through win32api or com) to tell >>a system to logout? >> >> > >OK; here I can help. If you want to do *any* work on Python/Win32, >I *strongly* recommend Mark Hammond / Andy Robinson's book on the >subject: Python Programming on Win32: >[http://www.oreilly.com/catalog/pythonwin32/] >You can get to it via O'Reilly's Safari, which I also recommend: >[http://safari.oreilly.com/1565926218] > >In Chapter 16, on page 305 in my edition, there's a description of >how to reboot a machine, which uses the win32api.InitiateSystemShutdown >function. I think it's already been discussed on this list; check >the archives: >http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/Python-win32 >or >http://mail.python.org/pipermail/python-win32/ > > >I don't have any experience myself of that particular approach, >so I'll leave others to follow up on that. >What I do have experience of is WMI. As you're using >W2000, you've got everything you need, so try the following: > >1) Download and install the WMI module from here: >http://tgolden.sc.sabren.com/python/wmi.html > >2) Check out the similar example here: >http://tgolden.sc.sabren.com/python/wmi_cookbook.html#reboot_remote_machine > >3) Try the following code: > >import wmi >c = wmi.WMI (privileges=["Shutdown"]) >for os in c.Win32_OperatingSystem (): > os.Win32Shutdown (Flags=0) > > > >Flags=0 is a logoff. The Win32Shutdown method is documented on MSDN: >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/ >win32shutdown_method_in_class_win32_operatingsystem.asp > >HTH >TJG > > >________________________________________________________________________ >This e-mail has been scanned for all viruses by Star Internet. The >service is powered by MessageLabs. For more information on a proactive >anti-virus service working around the clock, around the globe, visit: >http://www.star.net.uk >________________________________________________________________________ > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > From sfaulconer at cfl.rr.com Thu Jan 8 07:13:38 2004 From: sfaulconer at cfl.rr.com (Steven Faulconer) Date: Thu Jan 8 10:29:32 2004 Subject: [python-win32] Re: Window Location & Logout In-Reply-To: References: <3FFC9CD7.4020000@cfl.rr.com> Message-ID: <3FFD4972.8040907@cfl.rr.com> Thomas, I'll take a look at that function. Thanks. Steven Faulconer Thomas Heller wrote: >"Steven M. Faulconer" writes: > > > >>Hello Everyone, >> >>I've only been using Python for a short time, but I've enjoyed what >>I've done with it so far. I've written a login script for our systems >>that do various tasks, some of them are interactive. It works very >>well, except when the script runs at logon, the window is >>minimized. Is there a programatic way to tell the window to >>'unminimize' itself? >> >> > >A random idea, don't know if this works: there's a win32 >GetConsoleWindow() function which returns the console's window handle. > >You could try to call this, and then send messages to the window (if the >functions you need are not wrapped by win32all, try ctypes). > >Thomas > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > From harald.massa at suedvers.de Fri Jan 9 08:36:39 2004 From: harald.massa at suedvers.de (Massa, Harald) Date: Fri Jan 9 08:36:40 2004 Subject: [python-win32] py2exe, wxPython, resources Message-ID: <524506AA22C2104AA013A354F501D84C01390A1D@lorry.freiburg.suedvers.de> Hello, i learned from reading py2exe-source that I can include icon and bitmap-resources into my py2exe generated exe.file wxprog = dict( script = "dbeitrag.py", other_resources = [ (RT_MANIFEST, 1, manifest_template % dict(prog="zeiterfassung")), ], dest_base = r"prog\dbeitrag", icon_resources = [(01,"zerf.ico"),], ) Thats the Target-Defintiion ... just added icon_ressources the number before the resource is the icon-id - but: how can I access this resources from wxPython???? Harald -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040109/10aad244/attachment.html From harald.massa at suedvers.de Fri Jan 9 08:32:42 2004 From: harald.massa at suedvers.de (Massa, Harald) Date: Fri Jan 9 09:44:17 2004 Subject: [python-win32] py2exe, wxPython, resources Message-ID: <524506AA22C2104AA013A354F501D84C01390A1C@lorry.freiburg.suedvers.de> Hello, i learned from reading py2exe-source that I can include icon and bitmap-resources into my py2exe generated exe.file wxprog = dict( script = "dbeitrag.py", other_resources = [ (RT_MANIFEST, 1, manifest_template % dict(prog="zeiterfassung")), ], dest_base = r"prog\dbeitrag", icon_resources = [(01,"zerf.ico"),], ) Thats the Target-Defintiion ... just added icon_ressources the number before the resource is the icon-id - but: how can I access this resources from wxPython???? Harald -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040109/d0c8cffc/attachment.html From pzel at dodo.com.au Tue Jan 6 07:48:57 2004 From: pzel at dodo.com.au (Peter Zelezny) Date: Fri Jan 9 16:14:50 2004 Subject: [python-win32] pythonNN.dll and msvc's delayload (linking) Message-ID: <20040106234857.3385b4eb.pzel@dodo.com.au> Hi All, This is a question about python 2.3's dll file, and linking with it. I'm the author of xchat (www.xchat.org), and with it I distribute a plugin that allows you to run python scripts. Obviously, most windows users won't have python installed, so I still want the program to work, without the python features, when python23.dll is missing. The FAQ mentions using LoadLibrary/GetProcAddress... I think this is impractical, because you have to write different code for the windows and unix versions of the program. Trying to link it with MSVC's /delayload parameter, I get this error: LINK : fatal error LNK1194: cannot delay-load 'python23.dll' due to import of data symbol '__imp___Py_NoneStruct'; link without /DELAYLOAD:python23.dll I've actually used /delayload with "data" and "function" symbols before, and it hasn't caused any problems (with tcl and perl). Only with python2x.dll I get stuck. Does someone know what the problem could be? -- Peter. From Jack.Jansen at cwi.nl Fri Jan 9 16:27:43 2004 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Fri Jan 9 16:28:04 2004 Subject: [python-win32] Communicating symbols between extension modules Message-ID: Greetings, as I'm finally going to put some work again into porting the QuickTime package to Windows (at least: assuming no urgent matters turn up) I need a bit of help. The quicktime package will consist of a couple of extension modules and some Python modules, all nicely wrapped up in a package. The problem is that the extension modules need access to some symbols from other extension modules (within the same package). Specifically, the O& object encode/decode routines need to be available in other modules. On the Mac this problem is solved through a file mactoolboxglue.c that lives in the core python and which handles the indirection: a module that needs Movie objects calls PyMovieObj_New from mactoolboxglue.c and that routine has a pointer to the real conversion routine. If the pointer is NULL it knows that it has to import the "_Qt" module, which in its _Qtinit() routine will communicate the address of the real _PyMovieObj_New routine to mactoolboxglue.c, after which things are tied together. As this solution relies on support in the core Python DLL it won't work for QuickTime for Windows, so I need something else. I can think of numerous ways to solve this, but I'm not sure which solutions would work on Windows, and which one is best, so I'd like some thoughts on that, please. Here's a few ideas I have: - link all modules against a DLL that has the same function as mactoolboxglue, and put that DLL in the package. This would work if the extension modules would pick up this dll if it sat in the same directory. Is this so? - the same, but put the DLL in /System/Win32 or somesuch, like PyWinTypes does (or, at least, used to do when I last used PythonWin). I don't like this solution much, though. - make the glue code a true python module, and import/export routine pointers through cobjects. Should work on any platform, but has the disadvantage that it needs more magic in the C code. Any thoughts? -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From geek at cfl.rr.com Sat Jan 10 19:27:26 2004 From: geek at cfl.rr.com (Steven M. Faulconer) Date: Sat Jan 10 19:27:31 2004 Subject: [python-win32] Waiting for process & Intercepting Keys Message-ID: <4000986E.2040608@cfl.rr.com> Hello everyone, I'm my continuing drive to use Python more on our Windows systems, I've written a number of scripts to do certain tasks. One script is setup to do some time recording for usage information of the system. For the most part, the script works fine, but part of the script also locks the screen, and that is where I am having some minor issues. Please take note that I'm still a beginner, so I'm sure this is ugly: os.system("rundll32.exe user32.dll,LockWorkStation") This command will lock the work station correctly, the problem is I need the script to pause until the screen is unlocked. I'm a Unix man, and I've only a passing familiarity with the inner workings of Windows. Is this sort of thing possible? In the same vein, is it possible to intercept the CTL-ALT-DEL sequence in order to have my scripts pause the recording of time while the screen is locked? Right now, the users have an icon on their desktop to lock the screen, though it isn't working as well as I wanted (hence my question here). I'm not necessarily looking for code to do this, just a pointer to how to go about doing it. I've been looking at both the Win32 module and the WMI module, but nothing has caught my eye yet as to a possible solution to either question. Thanks for your time. Steven From phill at pacific.net.au Sun Jan 11 05:15:16 2004 From: phill at pacific.net.au (Phill) Date: Sun Jan 11 11:24:36 2004 Subject: [python-win32] Python extensions for Sequence types Message-ID: <000a01c3d82b$cf8fb180$44f464cb@me> Does anyone have an example of Python extensions for Sequence types, which I've not previously done. Anyone know of any simple clear examples? Phill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040111/3e160009/attachment.html From niki at vintech.bg Mon Jan 12 04:43:10 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Jan 12 04:48:28 2004 Subject: [python-win32] Communicating symbols between extension modules In-Reply-To: References: Message-ID: <40026C2E.5040900@vintech.bg> Jack Jansen wrote: > Greetings, > as I'm finally going to put some work again into porting the QuickTime > package to Windows (at least: assuming no urgent matters turn up) I need > a bit of help. > > The quicktime package will consist of a couple of extension modules and > some Python modules, all nicely wrapped up in a package. The problem is > that the extension modules need access to some symbols from other > extension modules (within the same package). Specifically, the O& object > encode/decode routines need to be available in other modules. > > On the Mac this problem is solved through a file mactoolboxglue.c that > lives in the core python and which handles the indirection: a module > that needs Movie objects calls PyMovieObj_New from mactoolboxglue.c and > that routine has a pointer to the real conversion routine. If the > pointer is NULL it knows that it has to import the "_Qt" module, which > in its _Qtinit() routine will communicate the address of the real > _PyMovieObj_New routine to mactoolboxglue.c, after which things are tied > together. > > As this solution relies on support in the core Python DLL it won't work > for QuickTime for Windows, so I need something else. I can think of > numerous ways to solve this, but I'm not sure which solutions would work > on Windows, and which one is best, so I'd like some thoughts on that, > please. > > Here's a few ideas I have: > - link all modules against a DLL that has the same function as > mactoolboxglue, and put that DLL in the package. This would work if the > extension modules would pick up this dll if it sat in the same > directory. Is this so? > - the same, but put the DLL in /System/Win32 or somesuch, like > PyWinTypes does (or, at least, used to do when I last used PythonWin). I > don't like this solution much, though. > - make the glue code a true python module, and import/export routine > pointers through cobjects. Should work on any platform, but has the > disadvantage that it needs more magic in the C code. > > Any thoughts? IMO Numeric has the same problem and solution to it. HTH Niki Spahiev From Jack.Jansen at cwi.nl Mon Jan 12 08:45:08 2004 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Mon Jan 12 08:44:48 2004 Subject: [python-win32] Communicating symbols between extension modules In-Reply-To: <40026C2E.5040900@vintech.bg> References: <40026C2E.5040900@vintech.bg> Message-ID: <88D728D3-4505-11D8-84BD-000A958D1666@cwi.nl> On 12-jan-04, at 10:43, Niki Spahiev wrote: >> - make the glue code a true python module, and import/export routine >> pointers through cobjects. Should work on any platform, but has the >> disadvantage that it needs more magic in the C code. >> Any thoughts? > > IMO Numeric has the same problem and solution to it. Indeed, except that I think it doesn't even use cobjects, but (brrrr) Python integers to hold addresses. At least, it did last time I examined the code. My reason for asking for other solutions is that I don't particularly like this way of doing things, so I hoped there would be an easier way to get things to work on Windows. Especially given the fact that I know that all the modules (and DLLs) involved will live in a single directory (which isn't true in case of Numeric, where third party modules will want access to the API). -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From tim.golden at viacom-outdoor.co.uk Tue Jan 13 04:24:19 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jan 13 04:32:35 2004 Subject: [python-win32] Waiting for process & Intercepting Keys Message-ID: >-----Original Message----- >From: Steven M. Faulconer [mailto:geek@cfl.rr.com] >Hello everyone, > > I'm my continuing drive to use Python more on our Windows > systems, I've written a number of scripts to do certain tasks. > One script is setup to do some time recording for usage > information of the system. For the most part, the script works > fine, but part of the script also locks the screen, and that > is where I am having some minor issues. Please take > note that I'm still a beginner, so I'm sure this is ugly: > > os.system("rundll32.exe user32.dll,LockWorkStation") I realise that you didn't ask for this, but this could slightly more cleanly be done like this, using ctypes (http://starship.python.net/crew/theller/ctypes/) import ctypes ctypes.windll.user32.LockWorkStation () > This command will lock the work station correctly, the problem > is I need the script to pause until the screen is unlocked. This looks to be really quite tricky. Technically you could install a Windows system hook, but I don't think they've been wrapped for Python (altho' again ctypes is a possibility) but I've always managed to avoid them, because hooking in to the O/S as such a low level makes me nervous. I'll try to have a look at a WMI-based solution, because that makes it easy to track process creation/death, but I don't think a new process is in fact created; I think it's the always-running winlogon.exe which is doing the business. Sorry not to be any more help than that. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Mark.English at liffe.com Tue Jan 13 04:36:06 2004 From: Mark.English at liffe.com (Mark English) Date: Tue Jan 13 04:42:05 2004 Subject: [python-win32] Communicating symbols between extension modules Message-ID: Hi, I'm still on the beginners slope writing Python extensions, and this may be stuff you already knew, but here's what came to mind: 1) Can't you use "PyImport_ImportModule()" if you need to call python code in another module from C ? Then lookup the appropriate python function object in the module dictionary, and call it ? This should be platform independent if a little clunky (I'm guessing this is what you meant by magic C code). 2) Many windows programs employ the trick of writing intermediary wrapper functions for the functions they're interested in from external dlls (including MFC). So if you want to call "Foo()" from 3rdParty.dll, you access it through a (module local) function pointer, which initially points at your own function "MyLoadFoo()". When first called, this loads the actual required function from 3rdParty.dll, points the global function pointer at that instead, and then calls the function. 3) An even more common windows trick is to use some module-specific definition when writing a module (e.g. FOO_PORTING) which under windows gets defined to either export symbols (when building the module), or import them (when importing as in your case). In this case, if the code you need is in 3rd party libraries with the appropriate header files (and .lib files have been provided), you can avoid Python entirely and just link to the code which will be loaded at runtime. From what I remember, a lot of the Python for windows code seems to be available as a plain dll... Hope that helps, Cheers, mE > -----Original Message----- > Message: 2 > Date: Fri, 9 Jan 2004 22:27:43 +0100 > From: Jack Jansen > Subject: [python-win32] Communicating symbols between extension > modules > > Greetings, > as I'm finally going to put some work again into porting the > QuickTime > package to Windows (at least: assuming no urgent matters turn up) I > need a bit of help. > > The quicktime package will consist of a couple of extension > modules and > some Python modules, all nicely wrapped up in a package. The > problem is > that the extension modules need access to some symbols from other > extension modules (within the same package). Specifically, the O& > object encode/decode routines need to be available in other modules. > ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From tim.golden at viacom-outdoor.co.uk Tue Jan 13 05:25:03 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jan 13 06:19:33 2004 Subject: [python-win32] Waiting for process & Intercepting Keys Message-ID: >-----Original Message----- >From: Steven M. Faulconer [mailto:geek@cfl.rr.com] [... snip locking workstation ...] > This command will lock the work station correctly, the problem > is I need the script to pause until the screen is unlocked. Well, thank you for the impetus this gave me to explore this area of Windows which I would otherwise never have gone near. Thanks to the combined efforts of the mighty Google, ctypes, and this article from DevX -- http://gethelp.devx.com/techtips/nt_pro/10_minute_solutions/10minNT0701.asp I can present the following stripped-down Python solution which seems to do what you want. Even if it doesn't, it was fun finding out! If it's not clear what's going on, I'm quite happy to elucidate, but since my knowledge is almost entirely secondhand, I'd suggest you look first at the article and check MSDN for the function calls. import time import ctypes user32 = ctypes.windll.User32 OpenDesktop = user32.OpenDesktopA SwitchDesktop = user32.SwitchDesktop DESKTOP_SWITCHDESKTOP = 0x0100 user32.LockWorkStation () while 1: hDesktop = OpenDesktop ("default", 0, False, DESKTOP_SWITCHDESKTOP) result = SwitchDesktop (hDesktop) if result: print "Unlocked" break else: print time.asctime (), "still locked" time.sleep (2) TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Jack.Jansen at cwi.nl Tue Jan 13 10:52:53 2004 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Tue Jan 13 10:52:57 2004 Subject: [python-win32] Communicating symbols between extension modules In-Reply-To: References: Message-ID: <8C333655-45E0-11D8-BD17-000A27B19B96@cwi.nl> On 13-jan-04, at 10:36, Mark English wrote: > Hi, > I'm still on the beginners slope writing Python extensions, and this > may > be stuff you already knew, but here's what came to mind: > 1) Can't you use "PyImport_ImportModule()" if you need to call python > code in another module from C ? Then lookup the appropriate python > function object in the module dictionary, and call it ? This should be > platform independent if a little clunky (I'm guessing this is what you > meant by magic C code). Right. But my problem is that I need to call *C* code from that other module: that code that I want to call is specifically meant to wrap/unwrap C objects from their corresponding Python objects.... -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From jens.jorgensen at tallan.com Tue Jan 13 12:30:31 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Jan 13 12:31:03 2004 Subject: [python-win32] Communicating symbols between extension modules In-Reply-To: <8C333655-45E0-11D8-BD17-000A27B19B96@cwi.nl> References: <8C333655-45E0-11D8-BD17-000A27B19B96@cwi.nl> Message-ID: <40042B37.6010309@tallan.com> Jack Jansen wrote: > > On 13-jan-04, at 10:36, Mark English wrote: > >> Hi, >> I'm still on the beginners slope writing Python extensions, and this may >> be stuff you already knew, but here's what came to mind: >> 1) Can't you use "PyImport_ImportModule()" if you need to call python >> code in another module from C ? Then lookup the appropriate python >> function object in the module dictionary, and call it ? This should be >> platform independent if a little clunky (I'm guessing this is what you >> meant by magic C code). > > > Right. But my problem is that I need to call *C* code from that other > module: that code that I want to call is specifically meant to > wrap/unwrap C objects from their corresponding Python objects.... So why not just call LoadLibrary/GetProcAddress on the other DLL? (Sorry, I skipped some other posts on this thread so if I'm ignoring something obvious I apologize.) Windoze is smart enough to see it alreay has the other DLL loaded and will just give you the handle to it. Just export the C functions you need in that other DLL and off you go. -- 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 Jack.Jansen at cwi.nl Tue Jan 13 15:37:22 2004 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Tue Jan 13 15:37:25 2004 Subject: [python-win32] Communicating symbols between extension modules In-Reply-To: <40042B37.6010309@tallan.com> References: <8C333655-45E0-11D8-BD17-000A27B19B96@cwi.nl> <40042B37.6010309@tallan.com> Message-ID: <49E521BE-4608-11D8-9F1A-000A27B19B96@cwi.nl> On 13-jan-04, at 18:30, Jens B. Jorgensen wrote: >> Right. But my problem is that I need to call *C* code from that other >> module: that code that I want to call is specifically meant to >> wrap/unwrap C objects from their corresponding Python objects.... > > So why not just call LoadLibrary/GetProcAddress on the other DLL? This sounds like an interesting solution. Just to double-check: I have two Python extension modules _Qt.pyd and _Cm.pyd and the first one needs the routine CmpObj_Convert from the latter one I can LoadLibrary(_Cm.pyd) and it will work both when _Cm.pyd has already been loaded through the normal import mechanism and when it hasn't, and a subsequent import will also work correctly? That leaves one question: can I get at the filename from where _Qt.pyd has been loaded? Because I would need that to construct the pathname for _Cm.pyd. -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From jens.jorgensen at tallan.com Tue Jan 13 17:03:49 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Jan 13 17:04:27 2004 Subject: [python-win32] Communicating symbols between extension modules In-Reply-To: <49E521BE-4608-11D8-9F1A-000A27B19B96@cwi.nl> References: <8C333655-45E0-11D8-BD17-000A27B19B96@cwi.nl> <40042B37.6010309@tallan.com> <49E521BE-4608-11D8-9F1A-000A27B19B96@cwi.nl> Message-ID: <40046B45.8060703@tallan.com> Jack Jansen wrote: > > On 13-jan-04, at 18:30, Jens B. Jorgensen wrote: > >>> Right. But my problem is that I need to call *C* code from that >>> other module: that code that I want to call is specifically meant to >>> wrap/unwrap C objects from their corresponding Python objects.... >> >> >> So why not just call LoadLibrary/GetProcAddress on the other DLL? > > > This sounds like an interesting solution. Just to double-check: I have > two Python extension modules _Qt.pyd and _Cm.pyd and the first one > needs the routine CmpObj_Convert from the latter one I can > LoadLibrary(_Cm.pyd) and it will work both when _Cm.pyd has already > been loaded through the normal import mechanism and when it hasn't, > and a subsequent import will also work correctly? Though I haven't tried it I cannot think of a reason why not. The only scenario I could think of where things could go astray is if you called LoadLibrary(_Cm.pyd) and then called a function in it which relied on the python module stuff in _Cm.pyd being initialized if it had not been. Even then though you could get around this by just asking Python to import the module before you LoadLibrary it yourself. > That leaves one question: can I get at the filename from where _Qt.pyd > has been loaded? Because I would need that to construct the pathname > for _Cm.pyd. I imagine that it is part of some internal struct that you could get a hold of. Well, let me just go and check. Well indeed in moduleobject.h I see: PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *); and I would be surprised if this is not function in question. -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions." -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3108 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20040113/fa4ba079/smime.bin From mmontagne at WalkerMacy.com Tue Jan 13 20:00:39 2004 From: mmontagne at WalkerMacy.com (Michael Montagne) Date: Tue Jan 13 20:00:43 2004 Subject: [python-win32] User Info from AD Message-ID: I'm trying to get a list of groups that an Active Directory user belongs to. It is win 2000. The .vbs function i'm trying to reproduce is: Function CreateMemberOfObject(strDomain, strUserName) ' Given a domain name and username, returns a Dictionary ' object of groups to which the user is a member of. ' ' Inputs: ' ' strDomain - Input, NT Domain name ' strUserName - Input, NT username ' Dim objUser, objGroup Set CreateMemberOfObject = CreateObject("Scripting.Dictionary") CreateMemberOfObject.CompareMode = vbTextCompare Set objUser = GetObject("WinNT://" & strDomain & "/" & strUserName & ",user") For Each objGroup In objUser.Groups CreateMemberOfObject.Add objGroup.Name, "-" Next Set objUser = Nothing End Function I'm not even really sure where to begin. Perhaps there is an easy way? -mjm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040113/9a81264e/attachment.html From tony at tcapp.com Tue Jan 13 20:04:36 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Jan 13 20:04:40 2004 Subject: [python-win32] Problem with WMI and CAMO in Python In-Reply-To: Message-ID: <20040113165901.C31750-100000@yamato.yamato.com> I'm running Python 2.3 on Windows 98 (I see the same problem on Windows 2000) I'm trying to import the wmi module from http://tgolden.sc.sabren.com/python/wmi.html When I do this, the following error message is displayed C:\WINDOWS\Desktop\Download\Python\TimGolden\wmi>python Python 2.3.3c1 (#50, Dec 4 2003, 21:27:34) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import wmi Traceback (most recent call last): File "", line 1, in ? File "wmi.py", line 117, in ? win32com.client.gencache.EnsureDispatch (obj._oleobj_) File "C:\PYTHON23\lib\site-packages\win32com\client\gencache.py", line 530, in EnsureDispatch raise TypeError, "This COM object can not automate the makepy process - plea se run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run make py manually for this object Unfortunately, the author- Tim Golden, doesn't know why this is happening, and suggested posting here. I've used the Makepy browser in PythonWin, but I don't see anything for WMI- I'm not sure what to look for actually. Has anyone here used WMI successfully with Python ? thanks From tony at tcapp.com Tue Jan 13 22:50:57 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Jan 13 22:50:58 2004 Subject: [python-win32] Problem with WMI and COM in Python (repost due to type in prev posting) Message-ID: <20040113194805.A34147-100000@yamato.yamato.com> >>Subject: Problem with WMI and CAMO in Python Sorry- that subject line in the original message should have read COM, not CAMO.. I'm running Python 2.3 on Windows 98 (I see the same problem on Windows 2000) I'm trying to import the wmi module from http://tgolden.sc.sabren.com/python/wmi.html When I do this, the following error message is displayed C:\WINDOWS\Desktop\Download\Python\TimGolden\wmi>python Python 2.3.3c1 (#50, Dec 4 2003, 21:27:34) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import wmi Traceback (most recent call last): File "", line 1, in ? File "wmi.py", line 117, in ? win32com.client.gencache.EnsureDispatch (obj._oleobj_) File "C:\PYTHON23\lib\site-packages\win32com\client\gencache.py", line 530, in EnsureDispatch raise TypeError, "This COM object can not automate the makepy process - plea se run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run make py manually for this object Unfortunately, the author- Tim Golden, doesn't know why this is happening, and suggested posting here. I've used the Makepy browser in PythonWin, but I don't see anything obviously for WMI. Has anyone here used Tim's wrapper for WMI successfully with Python ? thanks From tim.golden at viacom-outdoor.co.uk Wed Jan 14 03:24:12 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Jan 14 03:32:10 2004 Subject: [python-win32] User Info from AD Message-ID: > I'm trying to get a list of groups that an Active Directory user belongs to. It is win 2000. > [... snip most of .vbs function ...] OK. The important bit is this: Set objUser = GetObject("WinNT://" & strDomain & "/" & strUserName & ",user") which equates to this in python (assumes you have installed win32all extensions): import win32com.client domain_name = "VOUK" user_name = "goldent" user = win32com.client.GetObject ("WinNT://%s/%s,user" % (domain_name, user_name)) And then you just iterate over the user.Groups () method, like this: group_names = [] for group in user.Groups (): group_names.append (group.Name) print group_names The stuff with the dictionary you can ignore, because you'll be using Python's own structures: lists of Dicts depending on what you want to do. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From robin at reportlab.com Wed Jan 14 04:05:26 2004 From: robin at reportlab.com (Robin Becker) Date: Wed Jan 14 04:05:42 2004 Subject: [python-win32] Changing remote XP passwords Message-ID: I use the following to change Win2k passwords, but this doesn't work for a remote XP machine. win32net.NetUserChangePassword( r'\\remote2k', 'Administrator', current, next) Interestingly sysinternals pspasswd also failed to change remote passwords. Obviously there's something extra required to do this simple administrative task, but what? -- Robin Becker From Christian.Wyglendowski at greenville.edu Wed Jan 14 09:49:19 2004 From: Christian.Wyglendowski at greenville.edu (Christian Wyglendowski) Date: Wed Jan 14 09:49:26 2004 Subject: [python-win32] User Info from AD Message-ID: > -----Original Message----- > > I'm trying to get a list of groups that an Active Directory user > > belongs > to. It is win 2000. > > [... snip most of .vbs function ...] > > OK. The important bit is this: > > Set objUser = GetObject("WinNT://" & strDomain & "/" & strUserName & > ",user") You can also bind to the user object via LDAP: import win32com.client userDN = 'CN=Joe Schmoe, OU=Customer Support, OU=Employees, DC=yourdomain, DC=com' user = win32com.client.GetObject('LDAP://' + userDN) You can then get the groups that the user belongs to in this manner: for group in user.memberOf: print group I believe that LDAP is the "preferred" way to work with AD. Whether you prefer it or not, of course, is a different story ;-) Christian http://www.dowski.com From tim.golden at viacom-outdoor.co.uk Wed Jan 14 09:49:49 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Jan 14 10:00:05 2004 Subject: [python-win32] User Info from AD Message-ID: >-----Original Message----- >From: Christian Wyglendowski >[mailto:Christian.Wyglendowski@greenville.edu] >Sent: 14 January 2004 14:49 >To: Tim Golden; Michael Montagne; python-win32@python.org >Subject: RE: [python-win32] User Info from AD > > >> -----Original Message----- >> > I'm trying to get a list of groups that an Active Directory user >> > belongs >> to. It is win 2000. >> > [... snip most of .vbs function ...] >> >> OK. The important bit is this: >> >> Set objUser = GetObject("WinNT://" & strDomain & "/" & strUserName & >> ",user") > >You can also bind to the user object via LDAP: >import win32com.client >userDN = 'CN=Joe Schmoe, OU=Customer Support, OU=Employees, >DC=yourdomain, DC=com' >user = win32com.client.GetObject('LDAP://' + userDN) > >You can then get the groups that the user belongs to in this manner: > >for group in user.memberOf: > print group > >I believe that LDAP is the "preferred" way to work with AD. >Whether you >prefer it or not, of course, is a different story ;-) The advantage of the WinNT:// technique is that it works pre-AD, as well. I realise that the OP was talking about AD, but we're still on an NT4 domain here... TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Christian.Wyglendowski at greenville.edu Wed Jan 14 10:19:09 2004 From: Christian.Wyglendowski at greenville.edu (Christian Wyglendowski) Date: Wed Jan 14 10:19:12 2004 Subject: [python-win32] Problem with WMI and COM in Python (repost due to type in prev posting) Message-ID: > -----Original Message----- > I'm running Python 2.3 on Windows 98 (I see the same problem > on Windows > 2000) > > I'm trying to import the wmi module from > http://tgolden.sc.sabren.com/python/wmi.html > [snip error] > I've used the Makepy browser in PythonWin, but I don't see > anything obviously for WMI. I used PythonWin's makepy on the following libraries: Microsoft WMI Scripting V1.2 Library (1.2) WMI ADSI Extension Type Library (1.0) WMICntl 1.0 Type Library (1.0) > Has anyone here used Tim's wrapper for WMI successfully with Python ? I have used it with no problems. If I remember correctly though, I did run makepy on the above libraries previous to using it. I don't know if that makes a difference or not. Also, my platform is Windows XP, but I don't think that makes a difference as long as WMI is installed on your platform. Christian http://www.dowski.com From Mark.English at liffe.com Wed Jan 14 10:41:08 2004 From: Mark.English at liffe.com (Mark English) Date: Wed Jan 14 10:41:15 2004 Subject: [python-win32] Communicating symbols between extension modules Message-ID: Sorry, I didn't realise the two libraries were both written by you. That does simplify things. If exporting functions from one (_Cm.pyd) and importing them in the other (_Qt.pyd) is an option, then you can link one (_Qt.pyd) to the other (_Cm.pyd), which in msdev is known as creating a dependency, and then just call the _Cm.pyd code as though it were part of _Qt.pyd. In that sense, this is nothing to do with python - it's the standard way of exporting symbols from a dll and using them in another project (static linking). Static linking has some code maintenance and speed advantages over dynamic linking (dynamic linking is using LoadProcess, GetProcAddress). If you still need to call "LoadProcess()" and _Cm.pyd isn't in your path anyway, you can find out the path of your current module (_Qt.pyd) by calling "GetModuleHandle()" and then "GetModuleFileName()". Hope that all helps. Cheers, mE ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From Christian.Wyglendowski at greenville.edu Wed Jan 14 10:45:28 2004 From: Christian.Wyglendowski at greenville.edu (Christian Wyglendowski) Date: Wed Jan 14 10:45:42 2004 Subject: [python-win32] Changing remote XP passwords Message-ID: > -----Original Message----- > > I use the following to change Win2k passwords, but this > doesn't work for a remote XP machine. Does it return an error? If so, can you reply to the list with the error? > win32net.NetUserChangePassword( r'\\remote2k', 'Administrator', > current, next) > > Interestingly sysinternals pspasswd also failed to change > remote passwords. Hhhhmmm...shooting from the hip...this sounds like it might be a permissions problem since both NetUserChangePassword and pspasswd both fail - both are supposed to work fine with XP. > Obviously there's something extra required to do this simple > administrative task, but what? Perhaps you'll find something useful in Msoft's docs for NetUserChangePassword: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt /netmgmt/netuserchangepassword.asp Christian From robin at reportlab.com Wed Jan 14 14:02:29 2004 From: robin at reportlab.com (Robin Becker) Date: Wed Jan 14 14:04:21 2004 Subject: [python-win32] Changing remote XP passwords In-Reply-To: References: Message-ID: In message , Christian Wyglendowski writes >> -----Original Message----- >> >> I use the following to change Win2k passwords, but this >> doesn't work for a remote XP machine. > >Does it return an error? If so, can you reply to the list with the >error? > yes I get a permissions error of the form Traceback (most recent call last): File "", line 1, in ? error: (5, 'NetUserChangePassword', 'Access is denied.') so probably your hypothesis about NetUserChangePassword being involved stands. >> win32net.NetUserChangePassword( r'\\remote2k', 'Administrator', >> current, next) >> >> Interestingly sysinternals pspasswd also failed to change >> remote passwords. > >Hhhhmmm...shooting from the hip...this sounds like it might be a >permissions problem since both NetUserChangePassword and pspasswd both >fail - both are supposed to work fine with XP. > >> Obviously there's something extra required to do this simple >> administrative task, but what? > >Perhaps you'll find something useful in Msoft's docs for >NetUserChangePassword: >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt >/netmgmt/netuserchangepassword.asp > > >Christian > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Robin Becker From lehmanap at cs.purdue.edu Wed Jan 14 17:32:17 2004 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Wed Jan 14 17:32:22 2004 Subject: [python-win32] Python Dates and Windows dates In-Reply-To: References: Message-ID: <20040114223217.GA13055@lore.cs.purdue.edu> Hello-- How do I translate from the python time format to Windows time format? Aaron Lehmann -- Old hold for new construction. --Gene Ray www.timecube.com From can at optiver.com.au Wed Jan 14 18:01:41 2004 From: can at optiver.com.au (Christopher Nilsson) Date: Wed Jan 14 18:39:40 2004 Subject: [python-win32] Python Dates and Windows dates In-Reply-To: <20040114223217.GA13055@lore.cs.purdue.edu> References: <20040114223217.GA13055@lore.cs.purdue.edu> Message-ID: <4005CA55.5090400@optiver.com.au> This is an example of how I'm doing this... Might not be exactly what you're after though. import time, pywintypes def COMDateToDate(comdate): """Expects a PyTime object (a COMDate) as input - see the pythoncom doco for info""" return time.localtime(int(comdate)) def DateToCOMDate(adate): """Expects a datetime object (from datetime module)""" return pywintypes.Time(adate.timetuple()) Cheers, Chris. Aaron Patrick Lehmann wrote: >Hello-- > >How do I translate from the python time format to Windows time format? > >Aaron Lehmann > > -- ______________________________ Chris Nilsson | Developer | Optiver Australia m: 0428 880 242 | Paddington, Sydney w: 02 93334009 | http://www.optiver.com.au f: 02 93334044 |______________________________ Explicit leuctotem; da mihi potum From mmontagne at WalkerMacy.com Wed Jan 14 19:52:17 2004 From: mmontagne at WalkerMacy.com (Michael Montagne) Date: Wed Jan 14 19:52:22 2004 Subject: [python-win32] Mapping Drives and windows folders Message-ID: I. I'm using a combination like this to unmap drives so I can remap them due to a machine name change. But the drive will not disconnect because the share does not exist anymore. Is there aother way to disconnect a drive? import win32com.client wnt=win32com.client.Dispatch('Wscript.Network') wnt.RemoveNetworkDrive(driveletter) II. I need to manipulate users desktop contents at startup. Using vbscript, this works good. Set objFSO = CreateObject("Scripting.FileSystemObject") Set oShell = WScript.CreateObject("WScript.Shell") Set colEnvironmentVariables = oShell.Environment("Volatile") sFolder = colEnvironmentVariables.Item("APPDATA") & _ "\Microsoft\Internet Explorer\Quick Launch" set oFolder=objFSO.GetFolder(sFolder) sDesktopFolder=oShell.SpecialFolders.Item("Desktop") set oDesktopFolder=objFSO.GetFolder(sDesktopFolder) sAllDesktopFolder=oShell.SpecialFolders.Item("AllUsersDesktop") set oAllDesktopFolder=objFSO.GetFolder(sAllDesktopFolder) Then I walk the files collection looking for the ones I want to delete. But I'm having trouble with the Envoronment variables part using python. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040114/83820c3c/attachment.html From can at optiver.com.au Wed Jan 14 20:49:15 2004 From: can at optiver.com.au (Christopher Nilsson) Date: Wed Jan 14 20:49:24 2004 Subject: [python-win32] Mapping Drives and windows folders In-Reply-To: References: Message-ID: <4005F19B.9090405@optiver.com.au> Not sure about (II), but for (I), give this a go: import win32wnet def CloseConnection( name, revoke_permanency=True, force=True ): try: win32wnet.WNetCancelConnection2(name, revoke_permanency, force) except Exception, why: print 'Failed to close: %s\n%s' % (name, why) # Kill the evil network drive... CloseConnection("X:") The microsoft doco reckons that WNetCancelConnection2 should remove "remembered" connections like you're talking about, but I can't test that part myself at the moment (sorry). Cheers, Chris. Michael Montagne wrote: >I. >I'm using a combination like this to unmap drives so I can remap them >due to a machine name change. But the drive will not disconnect because >the share does not exist anymore. Is there aother way to disconnect a >drive? >import win32com.client >wnt=win32com.client.Dispatch('Wscript.Network') >wnt.RemoveNetworkDrive(driveletter) > >II. >I need to manipulate users desktop contents at startup. Using vbscript, >this works good. > >Set objFSO = CreateObject("Scripting.FileSystemObject") >Set oShell = WScript.CreateObject("WScript.Shell") >Set colEnvironmentVariables = oShell.Environment("Volatile") > >sFolder = colEnvironmentVariables.Item("APPDATA") & _ > "\Microsoft\Internet Explorer\Quick Launch" >set oFolder=objFSO.GetFolder(sFolder) > >sDesktopFolder=oShell.SpecialFolders.Item("Desktop") >set oDesktopFolder=objFSO.GetFolder(sDesktopFolder) > >sAllDesktopFolder=oShell.SpecialFolders.Item("AllUsersDesktop") >set oAllDesktopFolder=objFSO.GetFolder(sAllDesktopFolder) > > > Then I walk the files collection looking for the ones I want to delete. >But I'm having trouble with the Envoronment variables part using python. > > > > > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > From master at hilug.org Thu Jan 15 03:46:15 2004 From: master at hilug.org (HILUG) Date: Thu Jan 15 03:45:53 2004 Subject: [python-win32] win32evtlogutil.SafeFormatMessage don't work with some events Message-ID: <002f01c3db44$0a1233d0$dc3fe7cb@greatstream> Hi, I would like to monitor events about disk error of win2003 server. So I wrote a python code capture 'Disk' event or 'dmio' event. But I've realized win32evtlogutil.SafeFormatMessage() don't work with 'dmio' event. (also 'Serial', 'E1000', 'i8042prt' and so on) So I can't see description of 'dmio' event by my python code below. (but we can see the description by using windows event viewer.) import win32evtlog, win32evtlogutil def CheckRecord(record): if (record.SourceName == 'Disk' or record.SourceName == 'dmio'): if (record.EventType == 1): event_type = 'Error' elif (record.EventType == 2): event_type = 'Warning' elif (record.EventType == 4): event_type = 'Information' print "[%s] event '%s' (ID %d) at %s" % (event_type, record.SourceName, int(record.EventID), record.TimeWritten.Format()) print win32evtlogutil.SafeFormatMessage(record,'System') flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ win32evtlogutil.FeedEventLogRecords(CheckRecord,None,'System',flags) Any suggestion? Thanks! -- Y. H. Rhiu From tim.golden at viacom-outdoor.co.uk Thu Jan 15 03:45:13 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jan 15 03:53:16 2004 Subject: [python-win32] Mapping Drives and windows folders Message-ID: > ... But the drive will not disconnect because the share > does not exist anymore. Is there aother way to disconnect a drive? > import win32com.client > wnt=win32com.client.Dispatch('Wscript.Network') > wnt.RemoveNetworkDrive(driveletter) OK. In short, check out win32wnet from the win32all extensions. You're looking for things like: WNetCancelConnection2 and WNetAddConnection2 &c. If the wsh code fails, this might too, but after that you're down to editing the registry and other weird hacks like that. Can you give a dump of an interpreter output to show what happens? > I need to manipulate users desktop contents at startup. > Using vbscript, this works good. > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set oShell = WScript.CreateObject("WScript.Shell") > Set colEnvironmentVariables = oShell.Environment("Volatile") > sFolder = colEnvironmentVariables.Item("APPDATA") & _ > "\Microsoft\Internet Explorer\Quick Launch" > set oFolder=objFSO.GetFolder(sFolder) Although there are ways to get to the environment from within Python (os.environ and the _winreg module, for example), I suggest you look at: from win32com.shell import shell, shellcon print shell.SHGetPathFromIDList ( shell.SHGetSpecialFolderLocation (0, shellcon.CSIDL_APPDATA) ) or, if you're feeling lazy, have a look at the winshell module in: http://tgolden.sc.sabren.com/python/winshell.html which wraps this code lightly because I never remember what the constants are called. eg, to list all the files on the desktop: import os, sys import winshell desktop = winshell.desktop () for f in os.listdir (desktop): print f TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Thu Jan 15 04:03:31 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jan 15 04:11:44 2004 Subject: [python-win32] win32evtlogutil.SafeFormatMessage don't work w ith some events Message-ID: >I would like to monitor events about disk error of win2003 server. >So I wrote a python code capture 'Disk' event or 'dmio' event. > >But I've realized win32evtlogutil.SafeFormatMessage() don't >work with 'dmio' event. >So I can't see description of 'dmio' event by my python code below. >(but we can see the description by using windows event viewer.) I'm not an expert in event log stuff, but can I suggest this as an alternative method of monitoring: http://tgolden.sc.sabren.com/python/wmi_cookbook.html#monitor_error_events If you think it'll help and you're not sure how to alter it to suit what you're doing, I'm happy to help you adapt it. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From yeti_yzh at 163.com Thu Jan 15 04:33:01 2004 From: yeti_yzh at 163.com (Yeti) Date: Thu Jan 15 04:30:28 2004 Subject: [python-win32] listglobal/subject Message-ID: <200401150930.i0F9UKOo093192@mxzilla1.xs4all.nl> From yeti_yzh at 163.com Thu Jan 15 04:36:05 2004 From: yeti_yzh at 163.com (Yeti) Date: Thu Jan 15 04:33:34 2004 Subject: [python-win32] info? Message-ID: <200401150933.i0F9XPOo097208@mxzilla1.xs4all.nl> From yeti_yzh at 163.com Thu Jan 15 04:37:49 2004 From: yeti_yzh at 163.com (Yeti) Date: Thu Jan 15 04:35:18 2004 Subject: [python-win32] help? Message-ID: <200401150935.i0F9Z9Oo099467@mxzilla1.xs4all.nl> From yeti_yzh at 163.com Thu Jan 15 04:39:35 2004 From: yeti_yzh at 163.com (Yeti) Date: Thu Jan 15 04:37:03 2004 Subject: [python-win32] ? Message-ID: <200401150936.i0F9atg3053647@mxzilla2.xs4all.nl> From rasjidw at openminddev.net Thu Jan 15 05:25:54 2004 From: rasjidw at openminddev.net (Rasjid Wilcox) Date: Thu Jan 15 05:24:07 2004 Subject: [python-win32] help? In-Reply-To: <200401150935.i0F9Z9Oo099467@mxzilla1.xs4all.nl> References: <200401150935.i0F9Z9Oo099467@mxzilla1.xs4all.nl> Message-ID: <200401152125.54207.rasjidw@openminddev.net> Yeti, If you are trying to get the list help functionality, send a mail to: python-win32-request at python.org with subject 'help' View the mail headers for any mail from the list for further info. Cheers, Rasjid. -- Rasjid Wilcox Canberra, Australia (UTC +11 hrs) http://www.openminddev.net From nugentm at myrealbox.com Wed Jan 14 14:17:56 2004 From: nugentm at myrealbox.com (nugentm@myrealbox.com) Date: Thu Jan 15 07:58:22 2004 Subject: [python-win32] AD get user info script Message-ID: <000001c3db67$3f7bac90$0ac8340a@DD9XVG31> I wrote this script as a quick way to get AD properties of a LDAP object. Just make sure makepy is run on the ADO recordset library and rename to ADO.py LDAP://floex0ex01.ffci.com is our PDC emulator; it has all of the user objects on it. Just run the script and give a string to search. import ADO, time from string import atoi from win32com.client import GetObject def adoSearch(searchString): adoConnection=ADO.Connection() adoCommand=ADO.Command() adoRecordset=ADO.Recordset() adoConnection.Provider="ADsDSOObject" adoConnection.Open() command="Select ADsPATH from 'LDAP://floex0ex01.ffci.com' where cn='*%s*'" % searchString adoCommand.ActiveConnection=adoConnection adoCommand.CommandText=command adoRecordset.Open(adoCommand) adoRecordset.MoveLast() count=adoRecordset.RecordCount adoRecordset.MoveFirst() RecordsetList=[] for item in range(count): adspath=adoRecordset.Fields(0).Value RecordsetList.append(adspath) adoRecordset.MoveNext() return count,RecordsetList def adoGet(Path): obj=GetObject(Path) en=obj._NewEnum sch=GetObject(obj.Schema) for i in sch.MandatoryProperties: try: print i + " " + str(obj.Get(i)) except: pass for i in sch.OptionalProperties: try: if i in ['whenCreated','whenChanged']: print i + " " + str(obj.Get(i).Format()) else: print i + " " + str(obj.Get(i)) except: pass Searchstr=raw_input('Type in a String.') (rscount,rsList)= adoSearch(Searchstr) print rscount index=0 print " Index Path" for i in rsList: print " %s %s" % (index,i) index=index+1 print """ Please Select an Entry to Get """ Entry=atoi(raw_input('Entry?')) adoGet(rsList[Entry]) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040114/95952981/attachment.html From lbates at syscononline.com Thu Jan 15 08:55:14 2004 From: lbates at syscononline.com (Larry Bates) Date: Thu Jan 15 08:55:22 2004 Subject: [python-win32] Python Dates and Windows dates In-Reply-To: Message-ID: <011101c3db6f$341e2730$5d00a8c0@LABWXP> Here is some code from a project I did last year that seems to work. Note: You will need to get mx.DateTime from http://www.lemburg.com/files/python/mxDateTime.html (if you don't already have this excellent tool involved). FYI, Larry from mx.DateTime import DateTime from mx.DateTime import DateTimeFromCOMDate import time def strDateFromCOMDate(comdate, format): _trace=0 _debug=0 if _trace: print "Entering strDateFromCOMDate, comdate=%f, format=%s" % (comdate, format) # # Creates string date representation from COMDate # Format is a string defining what format you want the Date returned # in. See time.strftime format specifications in Python manuals for # description of format options (e.g. "%m/%d/%y" = MM/DD/YY). # t=DateTimeFromCOMDate(comdate) rdate=time.strftime(format, t.tuple()) if _trace: print "Leaving strDateFromCOMDate, date=%s" % rdate return rdate def COMDateFromstrDate(strdate): _trace=0 _debug=0 if _trace: print "Entering COMDateFromstrDate, strdate=%s" % strdate # # Creates a COM date representation from a string date (e.g. mm/dd/yy) # year=int(strdate[6:]) month=int(strdate[0:2]) day=int(strdate[3:5]) # # Handle possibility of pre-2000 years by using a 100 year sliding window # current_year=time.localtime()[0] # # Handle 2 digit years as well as 4 digit years # if year < 100: year+=1900 if year <= (current_year-100): year+=100 # # Create a DateTime instance with this information # t=DateTime(year, month, day) rdate=t.COMDate() if _trace: print "Leaving COMDateFromstrDate, COMDate=%f" % rdate return rdate ------------------------------ Message: 2 Date: Wed, 14 Jan 2004 17:32:17 -0500 From: Aaron Patrick Lehmann Subject: [python-win32] Python Dates and Windows dates To: python-win32@python.org Message-ID: <20040114223217.GA13055@lore.cs.purdue.edu> Content-Type: text/plain; charset=us-ascii Hello-- How do I translate from the python time format to Windows time format? Aaron Lehmann -- Old hold for new construction. --Gene Ray www.timecube.com From geek at cfl.rr.com Thu Jan 15 19:09:17 2004 From: geek at cfl.rr.com (Steven M. Faulconer) Date: Thu Jan 15 19:09:24 2004 Subject: [python-win32] Windows Server Share Info Message-ID: <40072BAD.1050100@cfl.rr.com> I'm looking into writing a script to hunt down all open shares (everyone permissions) on our servers and I'm having difficulties understanding something. Right now, this is what I've got: import win32net shares = win32net.NetShareEnum("", 2) shares is now a list, whith shares[0] being a list of dictionaries containing the share information and shares[1] being the number of shares found (please correct me if I am wrong). My problem is interpretting some of the values in the shares[0] list, mainly type and permissions. I've looked at the MSDN information, but it isn't being very helpful. The 'permissions' key always has a '0' value, which doesn't tell me much. The code is being executed by someone with administrator privileges on all systems. The type is similarly returning odd values, not quite what the MSDN site says it should. I'm getting large negative numbers instead of STYPE*. My guess is I'm doing this totally wrong, so any advice would be greatly appreciated. Thanks. Steven From master at hilug.org Thu Jan 15 22:22:53 2004 From: master at hilug.org (Y. H. Rhiu) Date: Thu Jan 15 22:22:58 2004 Subject: [python-win32] win32evtlogutil.SafeFormatMessage don't work with some events References: Message-ID: <001001c3dbe0$079e7bd0$dc3fe7cb@greatstream> I installed wmi module and excuted the code below. (I think wmi module is a little slow, but useful.) import wmi c = wmi.WMI (privileges=["Security"]) watcher = c.watch_for ( notification_type="Creation", wmi_class="Win32_NTLogEvent", Type="error" ) while 1: error = watcher () print "Error in %s log: %s" % (error.Logfile, error.Message) However, when "error = watcher ()" line is excuted, pythonwin is down. (I'm using PythonWin 2.3.2 and Windows 2003 Enterprise.) How can I fix it? -- Y.H. Rhiu > >I would like to monitor events about disk error of win2003 server. > >So I wrote a python code capture 'Disk' event or 'dmio' event. > > > >But I've realized win32evtlogutil.SafeFormatMessage() don't > >work with 'dmio' event. > >So I can't see description of 'dmio' event by my python code below. > >(but we can see the description by using windows event viewer.) > > I'm not an expert in event log stuff, but can I suggest this > as an alternative method of monitoring: > > http://tgolden.sc.sabren.com/python/wmi_cookbook.html#monitor_error_events > > If you think it'll help and you're not sure how to alter > it to suit what you're doing, I'm happy to help you > adapt it. > > TJG > > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star Internet. The > service is powered by MessageLabs. For more information on a proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Fri Jan 16 04:14:49 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Jan 16 04:23:09 2004 Subject: [python-win32] Windows Server Share Info Message-ID: >-----Original Message----- >From: Steven M. Faulconer [mailto:geek@cfl.rr.com] >Sent: 16 January 2004 00:09 >To: python-win32@python.org >Subject: [python-win32] Windows Server Share Info > > >I'm looking into writing a script to hunt down all open shares > >import win32net >shares = win32net.NetShareEnum("", 2) > My problem is >interpretting some of the values in the shares[0] list, mainly >type and >permissions. >From your reference to STYPE* you've obviously read this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/net mgmt/share_info_2_str.asp The STYPE things are Microsoft-defined constants. Some of these are wrapped in win32con; others aren't. These aren't. So it's time to go hunting. A Google for "STYPE_DISKTREE" gives a first hit of... the ActiveState Python 2.3 docs! (Is this good, or what?) which points us to win32security. win32security.STYPE_DISKTREE gives us: 0; win32security.STYPE_IPC is 3 and so on. If we convert your negative numbers to hex: hex (-2147483648) is 0x80000000 and hex (-2147483645) is 0x80000003 which is looking suspiciously close. Therefore... I can only assume (without bothering to read the source) that intentionally or otherwise, the top bit of this DWORD is being set to give you the 0x8... and negative numbers. If you, by whatever manipulation you wish, (eg type & 0x7fffffff), knock off the top bit you'll have the numbers defined in win32security. Wow. That was fun. (Sorry, this isn't meant to be snarky; sometimes you really feel you're being given the runaround by the API.) As to the permissions, I don't really know where to start. Of course... (you knew this was coming, didn't you) you could use WMI for this. It doesn't actually offer you much more, but by inspection, the Win32_Share class does have an AccessMask value which -- if absent -- suggests an open share. You'd have to fiddle, but something like this: import wmi import win32security c = wmi.WMI () for share in c.Win32_Share (): if (share.Type & 0x7fffffff) == win32security.STYPE_DISKTREE: print share.Name, share.Path, if share.AccessMask is None: print "No access control" else: print "Some access control" TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Fri Jan 16 04:35:07 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Jan 16 04:43:18 2004 Subject: [python-win32] Windows Server Share Info Message-ID: >Of course... (you knew this was coming, didn't you) you could > use WMI for this. It doesn't actually offer you much more, but > by inspection, the Win32_Share class does have an AccessMask > value which -- if absent -- suggests an open share. You'd have > to fiddle, but something like this: > OK. I'll come clean. I didn't check the WMI docs before I sent out that code. For the *real* deal with the share.Type constants under WMI, check out this page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/ win32_share.asp Caveat: from my experience on Win2K, AccessMask *is* defined and GetAccessMask *isn't* available. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From lehmanap at cs.purdue.edu Sat Jan 17 22:11:49 2004 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Sat Jan 17 22:11:58 2004 Subject: [python-win32] GUIDs and Microsoft Property sets in Exchange Message-ID: <20040118031149.GA27440@lore.cs.purdue.edu> I'm writing an electronic secretary program for the Computer Science department here, and I've hit a snag regarding contacts with multiple e-mails. Outlook allows a contact to have up to three e-mail addresses, and I'd like to do likewise with mine. The best I can come up with is to make three seperate contacts with same name and diferent e-mail addresses. This seems kindof hacky to me. Googling aound has turned up some hits that suggest that if I were able to use a different MAPI property set, I'd have access to more e-mail address space. However, I can't seem to get the SetNameSpace function, which is what I think I have to use to get at the alternate property sets, to work. Has anyone here done the sort of thing I'm talking about? Any suggestions about how to go about doing this? Aaron Lehmann -- Old hold for new construction. --Gene Ray www.timecube.com From tim.golden at viacom-outdoor.co.uk Mon Jan 19 04:55:44 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Jan 19 05:03:50 2004 Subject: [python-win32] GUIDs and Microsoft Property sets in Exchange Message-ID: >From: Aaron Patrick Lehmann [mailto:lehmanap@cs.purdue.edu] > >I'm writing an electronic secretary program for the Computer Science >department here, and I've hit a snag regarding contacts with multiple >e-mails. > [... snip explanation of problem ...] > >Has anyone here done the sort of thing I'm talking about? Any >suggestions >about how to go about doing this? I realise that this isn't quite what you were asking for, but I have found this book to be *extremely* useful when doing work on the Outlook / Exchange front: http://safari.oreilly.com/?XmlId=1-56592-665-X This is the Safari reference. If you don't use Safari (and I wholeheartedly recommend it) then I'm sure you can find the book to buy somewhere. HTH TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From null-python-win32 at tinfoilhat.ca Mon Jan 19 14:28:38 2004 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Mon Jan 19 14:31:44 2004 Subject: [python-win32] Terminal RPC failure. Message-ID: It seems now every time I run anything using WMI (computer browser, my python scripts) I get a 'Generic Host Process for Win32 Services' failure. I've repeated this on two computers (both using XP Pro). The error signature is: szAppName: svchost.exe szAppVer: 5.1.2600.0 szModName: rpcrt4.dll szModVer: 5.1.2600.1254 offset: 00001841 Shortly after this displays the system is forcefully shut down (gives me a minute then just shuts down). Message: Windows must now restart because the Remote Procedure Call (RPC) service terminated unexpectedly. I'm completely baffled by this as these scripts and applications worked last month with no difficulties and nothing has changed on my PC. Any ideas or suggestions on where to look would be greatly appriciated, -- Sean From pythonwin at evpopov.com Mon Jan 19 16:11:44 2004 From: pythonwin at evpopov.com (pythonwin) Date: Mon Jan 19 16:13:02 2004 Subject: [python-win32] Terminal RPC failure. Message-ID: <1074546704.400c481084c33@imp.online.net> > it seems now every time I run anything using WMI (computer browser, my > python scripts) I get a 'Generic Host Process for Win32 Services' failure. 'Blaster' worm ? http://securityresponse.symantec.com/avcenter/venc/data/w32.blaster.worm.removal .tool.html From lehmanap at cs.purdue.edu Mon Jan 19 16:35:57 2004 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Mon Jan 19 16:36:01 2004 Subject: [python-win32] GUIDs and Microsoft Property sets in Exchange In-Reply-To: References: Message-ID: <20040119213556.GB16924@lore.cs.purdue.edu> For anyone interested I figured out the solution. It appears there are two ways to get at a contact's address in CDO. The way I started out using is the AddressLists member in the Session object. This will get you all contacts, listed once for each e-mail. The other way is through the GetDefaultFolder() method, supplying a parameter of 5, which is the constant that indicates a contact folder. This will ultimately get you to a Messages collection, where each message represents a contact. Then, you can add to the standard MAPI fields there, as well as access other Property Sets if you have the right ID. www.cdolive.com/cdo5.htm has a fairly decent rundown of how to do what I wanted in VB, if you search the page for CdoPropSetID your browser will jump to the right part of the page. In Python, I found an easier way was to create a new AddressEntry with just a name through the .AddressLists("Contacts").AddressEntries field, then look up the equivalent message in the .GetDefaultFolder(5).Messages field to customize it. Thanks all, Aaron Lehmann On Mon, Jan 19, 2004 at 09:55:44AM -0000, Tim Golden wrote: > >From: Aaron Patrick Lehmann [mailto:lehmanap@cs.purdue.edu] > > > >I'm writing an electronic secretary program for the Computer Science > >department here, and I've hit a snag regarding contacts with multiple > >e-mails. > > > [... snip explanation of problem ...] > > > >Has anyone here done the sort of thing I'm talking about? Any > >suggestions > >about how to go about doing this? > > I realise that this isn't quite what you were asking for, but > I have found this book to be *extremely* useful when doing work > on the Outlook / Exchange front: > > http://safari.oreilly.com/?XmlId=1-56592-665-X > > This is the Safari reference. If you don't use Safari (and I > wholeheartedly recommend it) then I'm sure you can find the > book to buy somewhere. > > HTH > TJG > > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star Internet. The > service is powered by MessageLabs. For more information on a proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________ -- Old hold for new construction. --Gene Ray www.timecube.com From null-python-win32 at tinfoilhat.ca Mon Jan 19 17:32:11 2004 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Mon Jan 19 17:35:18 2004 Subject: [python-win32] Terminal RPC failure. In-Reply-To: <1074546704.400c481084c33@imp.online.net> Message-ID: ->'Blaster' worm ? -> Unfortunately no. Never thought I would say that. We have a site licence for NoD and the mail server is pretty pedantic. Thanks for the suggestion though. -- Sean From hameedkhaan at yahoo.com Tue Jan 20 13:47:15 2004 From: hameedkhaan at yahoo.com (Hameed Khan) Date: Tue Jan 20 14:25:31 2004 Subject: [python-win32] how can we get list of all drives in Python Message-ID: <20040120184715.57368.qmail@web61107.mail.yahoo.com> hello all, i was wondering how can i get list of all drives available on my windows platform. is there any function or something from which can i build a list of all drives on my window platform. Thanks, Hameed khan __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus From jens.jorgensen at tallan.com Tue Jan 20 15:05:59 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Jan 20 15:06:46 2004 Subject: [python-win32] how can we get list of all drives in Python In-Reply-To: <20040120184715.57368.qmail@web61107.mail.yahoo.com> References: <20040120184715.57368.qmail@web61107.mail.yahoo.com> Message-ID: <400D8A27.4000404@tallan.com> from win32com.client import Dispatch fso = Dispatch('scripting.filesystemobject') for i in fso.Drives : print i Hameed Khan wrote: >hello all, > i was wondering how can i get list of all drives >available on my windows platform. is there any >function or something from which can i build a list >of all drives on my window platform. > >Thanks, >Hameed khan > >__________________________________ >Do you Yahoo!? >Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes >http://hotjobs.sweepstakes.yahoo.com/signingbonus > >_______________________________________________ >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." -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3108 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20040120/1aa1fd3e/smime.bin From lehmanap at cs.purdue.edu Tue Jan 20 18:11:47 2004 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Tue Jan 20 18:11:52 2004 Subject: [python-win32] Extremely long hex ID's Message-ID: <20040120231147.GA20880@lore.cs.purdue.edu> I'm using CDO to access Calendar appointments and Contacts on an exchange server. Occasionally I've come across large Hex-formatted strings of numbers as values in the Fields of my contacts. Is there any way to find out what these numbers represent? I believe, in the particular case I'm working on, that it would help me to get what I want done ( duplicate the way Outlook sets up contact information that knows which contacts know one another ). Any help is much appreciated, Aaron Lehmann -- Old hold for new construction. --Gene Ray www.timecube.com From Rudy.Schockaert at pandora.be Wed Jan 21 02:25:01 2004 From: Rudy.Schockaert at pandora.be (Rudy Schockaert) Date: Wed Jan 21 02:25:08 2004 Subject: [python-win32] Extremely long hex ID's In-Reply-To: <20040120231147.GA20880@lore.cs.purdue.edu> References: <20040120231147.GA20880@lore.cs.purdue.edu> Message-ID: <400E294D.3010604@pandora.be> Aaron Patrick Lehmann wrote: >I'm using CDO to access Calendar appointments and Contacts on an exchange >server. Occasionally I've come across large Hex-formatted strings of >numbers as values in the Fields of my contacts. Is there any way to find >out what these numbers represent? I believe, in the particular case I'm >working on, that it would help me to get what I want done ( duplicate the >way Outlook sets up contact information that knows which contacts know one >another ). > >Any help is much appreciated, > >Aaron Lehmann > > Patrick, I always use OutlookSpy (http://dimastr.com) to examine the fields of MAPI objects. That in comination with MSDN normally gives me enough clues to determine the kind of values a MAPI property holds. Unfortunately not all attributes are documented. Rudy From karthik19_20 at yahoo.com Thu Jan 22 01:33:43 2004 From: karthik19_20 at yahoo.com (karthik karthik) Date: Thu Jan 22 01:33:48 2004 Subject: [python-win32] problem in creating object of a class in external dll. Message-ID: <20040122063343.72495.qmail@web11901.mail.yahoo.com> hi! i'm using textract.dll for capturing the font information for my project. i'm enclosing the textract.h file which exposes the functions for capturing the font information. in my python file i coded as: from ctypes import * class txtRact: def __init__(self): self.txtrct = windll.LoadLibrary("C:\\Textract\\textract.dll") self.src = self.txtrct.TextractSource() the last line is giving the following error: " Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\lib\site-packages\ctypes\__init__.py", line 250, in __getattr__ func = self._StdcallFuncPtr(name, self) AttributeError: function 'TextractSource' not found " now how can i create an object for that class so tht i can access the methods in tht class? can anyone help... ===== thanks and regards, Karthik. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -------------- next part -------------- // Textract Screen Text Capture Library. Textract.DLL C++ API // Textract.H // Copyright 1996-2002 by Structu Rise, support@structurise.com // Written Mar'99 by Pavel Senatorov, manager@structurise.com #ifndef TextractH #define TextractH #ifndef assert #include #endif #ifndef cdef #define cdef extern "C" #endif #define TextractExport cdef __declspec(dllexport) TextractExport const char *TextractIniFileName(); TextractExport const char *TextractBaseFileName(); TextractExport const char *TextractBitmapFileName(); TextractExport const char *TextractFakeResFileName(); typedef long TextractSuccess; // success returning code for Textract functions enum { // value definitions for TextractSuccess tsOK = 0, tsReject = -1000, tsBadArgs, tsBadBitmap, tsOutOfWindow, tsIniNotFound, tsBaseNotFound, tsBitmapNotFound, tsFakeResNotFound, tsInitFailed, tsTermFailed, tsFormat, tsNoAccess, tsDouble, tsTooMany, tsCrash, }; TextractExport TextractSuccess TextractInit(); TextractExport TextractSuccess TextractTerm(); TextractExport TextractSuccess TextractBuild(); TextractExport TextractSuccess TextractBuildWithDialog(); class TextractSource { public: TextractSource(); TextractSource& BmpFile(const char *bmpFileName); TextractSource& Wnd(HWND); TextractSource& Rect(int ax, int ay, int bx, int by); TextractSource& DesktopWnd(); TextractSource& TopWnd(const char *windowClass, const char *windowText); TextractSource& DeepWnd(const char *windowClass, const char *windowText); TextractSource& SubWnd(const char *windowClass, const char *windowText); TextractSource& SubDeepWnd(const char *windowClass, const char *windowText); TextractSource& FindLargestWindow(); const char *BmpFileName; // used if != NULL HWND W; // used if != NULL int AX, AY, BX, BY; // used if BmpFileName == NULL and Wnd == NULL }; class TextractDest { public: TextractDest(const char *destFileName); TextractDest(); ~TextractDest(); const char *FileName; // NULL if area specifeid, else dest file name void *Area; // NULL if file name specified, else memory area int AreaSize; }; TextractExport TextractSuccess TextractDestFree(TextractDest&); enum TextractDestFormat { dfText, dfRtf, dfVerbose, dfBinary, dfBmp, dfBol = 0x0100, dfEol = 0x0200, dfSpace = 0x0400, dfChar = 0x0800, dfFont = 0x1000, dfCharHex = 0x2000, dfCharFont = 0x4000, dfCharColor = 0x8000 }; enum TextractItemType { itChar, // ordinary character itSpace, // character gap, defined as space itLineStart, // start of the new line itLineTerm, // end of the currect line itFont // change to another font face/name/style }; class TextractItem { public: TextractItemType Type :8; short OffsetX, OffsetY; // relative to upper left corner of the image unsigned short FontIndex; // internal Textract font index, suitable for font compare const char *FontName; char Ch; unsigned long Color; // RGB color, coded as COLORREF unsigned char Pitch; // font picth size short Spacing; int IsExactSpacing : 8; }; TextractExport TextractSuccess Textract(TextractSource&, TextractDest&, TextractDestFormat); TextractExport void TextractSourceLargestWnd(TextractSource*); TextractExport void TextractSourceDeepWnd(TextractSource*, HWND, const char *windowClass, const char *windowText); TextractExport void TextractSourceDesktopWnd(TextractSource*); TextractExport void TextractSourceTopWnd(TextractSource*, const char *windowClass, const char *windowText); TextractExport void TextractSourceSubWnd(TextractSource*, HWND, const char *windowClass, const char *windowText); // ---- inline implementations inline TextractSource::TextractSource(){ BmpFileName = NULL; W = NULL; AX = 0; AY = 0; BX = 0; BY = 0; } inline TextractSource& TextractSource::BmpFile(const char *bmpFileName){ assert(BmpFileName == NULL && W == NULL); BmpFileName = bmpFileName; return *this; } inline TextractSource& TextractSource::Rect(int ax, int ay, int bx, int by){ assert(BmpFileName == NULL && W == NULL); AX = ax; AY = ay; BX = bx; BY = by; return *this; } inline TextractSource& TextractSource::Wnd(HWND wnd){ assert(BmpFileName == NULL && W == NULL); W = wnd; return *this; } inline TextractSource& TextractSource::DesktopWnd(){ assert(BmpFileName == NULL && W == NULL); TextractSourceDesktopWnd(this); return *this; } inline TextractSource& TextractSource::TopWnd(const char *windowClass, const char *windowText){ assert(BmpFileName == NULL && W == NULL); TextractSourceTopWnd(this, windowClass, windowText); return *this; } inline TextractSource& TextractSource::DeepWnd(const char *windowClass, const char *windowText){ assert(BmpFileName == NULL && W == NULL); TextractSourceDeepWnd(this, GetDesktopWindow(), windowClass, windowText); return *this; } inline TextractSource& TextractSource::SubDeepWnd(const char *windowClass, const char *windowText){ assert(BmpFileName == NULL && W != NULL); TextractSourceDeepWnd(this, W, windowClass, windowText); return *this; } inline TextractSource& TextractSource::SubWnd(const char *windowClass, const char *windowText){ assert(BmpFileName == NULL && W != NULL); TextractSourceSubWnd(this, W, windowClass, windowText); return *this; } inline TextractSource& TextractSource::FindLargestWindow(){ assert(BmpFileName == NULL && W == NULL); TextractSourceLargestWnd(this); return *this; } inline TextractDest::TextractDest(const char *destFileName){ FileName = destFileName; Area = 0; } inline TextractDest::TextractDest(){ FileName = 0; Area = 0; } inline TextractDest::~TextractDest(){ TextractDestFree(*this); } #endif From theller at python.net Thu Jan 22 03:43:35 2004 From: theller at python.net (Thomas Heller) Date: Thu Jan 22 03:43:55 2004 Subject: [python-win32] Re: problem in creating object of a class in external dll. References: <20040122063343.72495.qmail@web11901.mail.yahoo.com> Message-ID: karthik karthik writes: > hi! > i'm using textract.dll for capturing the font > information for my project. i'm enclosing the > textract.h file which exposes the functions for > capturing the font information. > > in my python file i coded as: > > from ctypes import * > class txtRact: > def __init__(self): > self.txtrct = > windll.LoadLibrary("C:\\Textract\\textract.dll") > self.src = self.txtrct.TextractSource() > > the last line is giving the following error: > > " > Traceback (most recent call last): > File "", line 1, in ? > File > "C:\Python23\lib\site-packages\ctypes\__init__.py", > line 250, in __getattr__ > func = self._StdcallFuncPtr(name, self) > AttributeError: function 'TextractSource' not found > " > > now how can i create an object for that class so tht i > can access the methods in tht class? > > can anyone help... >From reading the include file, it seems that TextractSource is not a function but a C++ class definition. I don't think ctypes is able to handle that. Thomas From karthik19_20 at yahoo.com Thu Jan 22 05:14:08 2004 From: karthik19_20 at yahoo.com (karthik karthik) Date: Thu Jan 22 05:14:12 2004 Subject: [python-win32] how to generate scroll wheel mouse event. Message-ID: <20040122101408.63590.qmail@web11903.mail.yahoo.com> hi! i'm trying to generate all mouse events using, "win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,100,100,0)" and got stuck up in generating scroll wheel mouse events such as scroll wheel up, scroll wheel down and scroll wheel click. may i know the appropriate call? ===== thanks and regards, Karthik. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ From doug.schieszer at sprintsvslabs.com Fri Jan 23 16:25:55 2004 From: doug.schieszer at sprintsvslabs.com (Douglas F. Schieszer) Date: Fri Jan 23 16:38:48 2004 Subject: [python-win32] Printing with COM triggered by a python cgi script Message-ID: <1582.144.230.97.131.1074893155.squirrel@mail.sprintsvslabs.com> I am trying to learn how to create a python cgi web application. I have created a module that I want to use to print a reciept using the python com interface that is based on the "Interfacing with COM" example in learning python 1st edition. I will include it below. This print_testdrive() function works fine when called from a command line with the proper objects as arguments, but when I execute it as part of a cgi script it gives no errors but does not print anything. Any ideas what I have done wrong? reciept.py: from win32com.client import constants, Dispatch WORD = 'Word.Application' False, True = 0, -1 import string class Word: def __init__(self): self.app = Dispatch(WORD) def open(self, doc): self.app.Documents.Open(FileName=doc) def replace(self, source, target): self.app.Selection.HomeKey(Unit=constants.wdLine) find = self.app.Selection.Find find.Text = "%" + source + "%" self.app.Selection.Find.Execute() self.app.Selection.TypeText(Text=target) def printdoc(self): self.app.Application.PrintOut() def close(self): self.app.ActiveDocument.Close(SaveChanges=False) def print_testdrive(customer, vehicle, appointment): word = Word() word.open(r"c:\Program Files\Apache Group\Apache2\htdocs\templates\testdrive.doc") if customer.nameprefix: word.replace("nameprefix",customer.nameprefix) else: word.replace("nameprefix", " ") if customer.firstname: word.replace("firstname",customer.firstname) else: word.replace("firstname", " ") if customer.middlename: word.replace("middlename",customer.middlename) else: word.replace("middlename", " ") if customer.lastname: word.replace("lastname",customer.lastname) else: word.replace("lastname", " ") if customer.namesuffix: word.replace("namesuffix",customer.namesuffix) else: word.replace("namesuffix", " ") word.replace("time",appointment.time) word.replace("date",appointment.date) word.replace("reservation",appointment.reservation) word.replace("VIN",vehicle.VIN) word.replace("Make",vehicle.Make) word.replace("Model",vehicle.Model) word.replace("Color",vehicle.Color) word.replace("OptionPackage",vehicle.OptionPackage) word.replace("Accessories",vehicle.Accessories) word.replace("ModelYear",vehicle.ModelYear) word.printdoc() word.close() From maketo at sdf.lonestar.org Sun Jan 25 23:04:23 2004 From: maketo at sdf.lonestar.org (Ognen Duzlevski) Date: Sun Jan 25 23:04:26 2004 Subject: [python-win32] ReadDirectoryChangesW question Message-ID: Hi, I am new to pywin32 and am a bit confused by the documentation. Is it possible to use win32file.ReadDirectoryChangesW() in an asynchronous manner and if so, can someone explain (briefly) how or point me to some source of info? Thank you very much, Ognen From b.hall at irl.cri.nz Sun Jan 25 23:05:40 2004 From: b.hall at irl.cri.nz (Blair Hall) Date: Sun Jan 25 23:06:27 2004 Subject: [python-win32] "Application Error" Message-ID: <5.2.0.9.1.20040126164755.00bd7c90@127.0.0.1> It may be asking too much for help on this, but there's no harm in asking I guess. I have found myself with a problem that throws up a "PythonWin: Pythonwin.exe Application Error". This dialog message that appears just before Python shuts down. The error message reads: "The instruction at xxx referenced memory at xxx The memory could not be read." I can't make any sense out of what might be happening to cause this. The problem is triggered by a call to a little function def norm(z): "2-norm of complex argument: |z|^2 " z_star = conj(z) return z * z_star and I can make the problem disappear if I expand that call by this definition. However, 'norm' works fine elsewhere. Oh, and it doesn't crash each time either. Depending on how I arrange the code, it can run fine a couple of times and then crash. Unfortunately, there is a fair bit of code in the backgound to all this supporting an abstract data type. I haven't been able to distill the problem into a nice short piece of code. Funny thing is, I can run the same script from the command line and no error seems to occur. (I'm using Python 2.2.2 and win32all build 152) Any ideas? From davidlinke at tiscali.de Mon Jan 26 12:17:39 2004 From: davidlinke at tiscali.de (David Linke) Date: Mon Jan 26 12:35:54 2004 Subject: [python-win32] How to pass OleVariant Array from Python to COM server Message-ID: <40154BB3.4030102@tiscali.de> Hi! I am using win32com to interface a COM server (QuickStartEngine/Galaxie for controlling data aquisition software for chromatographs). I can use most of the functions of the server without problems. However there is one function does not work. This function must be called with "OleVariant Arrays" in the parameter list. A helpful person from the product support found out that Python passes a Variant but not a variant array (errmsg: 'Variant is not an array'). I tried to find helpful advice in google how to solve that problem but did not find something helpful. I tried early (via makepy) and late binding or to pass different python types: tuple, tuple of tuple, list, list of list etc. -- Nothing helped to solve the problem. How can I force win32com to pass a variant array as needed? Maybe by modifying the makepy generated wrapper? Since I am not an expert in COM I would appreciate your help very much. Best regards, David From mmontagne at walkermacy.com Mon Jan 26 16:32:50 2004 From: mmontagne at walkermacy.com (michael montagne) Date: Mon Jan 26 16:32:56 2004 Subject: [python-win32] Directory permissions Message-ID: <40158782.7040003@walkermacy.com> I'm using this code to make directories at login(fso is fso=win32com.client.Dispatch('Scripting.FileSystemObject') : #home directory sDir="\\\\wmserver1\\Home\\" + sUser #check that directory exists if not fso.FolderExists(sDir): fso.CreateFolder(sDir) Trouble is, the permissions are wide open to the world. I need to give the administrator and the user full control but no other access to anyone. Even if I could run a script after the fact and correct all the permissions that would be ok. -mjm From dave at psys.org Mon Jan 26 17:27:16 2004 From: dave at psys.org (d.w. harks) Date: Mon Jan 26 17:27:21 2004 Subject: [python-win32] Directory permissions In-Reply-To: <40158782.7040003@walkermacy.com> References: <40158782.7040003@walkermacy.com> Message-ID: <20040126222716.GB11505@psys.org> With carefully-arranged electrons, michael montagne wrote: > I'm using this code to make directories at login(fso is > fso=win32com.client.Dispatch('Scripting.FileSystemObject') : > > #home directory > sDir="\\\\wmserver1\\Home\\" + sUser > #check that directory exists > if not fso.FolderExists(sDir): > fso.CreateFolder(sDir) > Trouble is, the permissions are wide open to the world. I need to give > the administrator and the user full control but no other access to > anyone. Even if I could run a script after the fact and correct all the > permissions that would be ok. > > -mjm Check the archives; there was some code posted to this list a while ago which manipulates Windows ACLs. You can do it either with the ADSI security DLL interface, or directly via the win32 api. dave -- David W. Harks http://dwblog.psys.org From tony at tcapp.com Mon Jan 26 22:04:25 2004 From: tony at tcapp.com (Tony Cappellini) Date: Mon Jan 26 22:04:45 2004 Subject: [python-win32] Object hierarchy for Windows Desktop-Properties-Screensaver In-Reply-To: Message-ID: <20040126190141.K64294-100000@yamato.yamato.com> I'm looking for a way to access the Screensaver Tab, under DEsktop-Properties, via Python There are no useable references to screensaver in this mailing list, and refernces to Desktop were not what I'm looking for. thanks From tim.golden at viacom-outdoor.co.uk Tue Jan 27 05:52:41 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jan 27 06:00:53 2004 Subject: [python-win32] Object hierarchy for Windows Desktop-Propertie s-Screensaver Message-ID: >From: Tony Cappellini [mailto:tony@tcapp.com] > >I'm looking for a way to access the Screensaver Tab, under >DEsktop-Properties, via Python > >There are no useable references to screensaver in this mailing >list, and >refernces to Desktop were not what I'm looking for. > Tony. Do you really mean that you want to get programmatic control of that tab in that window? Or do you mean that you want access to the properties of the screensaver? If the former, then you're going to have to fiddle around with the sort of stuff Simon Brunning's done: http://www.brunningonline.net/simon/blog/archives/001129.html If the latter, then you want to look in the registry under (for my Win2k box): HKCU\Control Panel\Desktop for things like: ScreenSaverIsSecure ScreenSaveTimeOut and under HKCU\Control Panel for Screen Saver.Marquee Screen Saver.Mystify etc. Does that help at all? TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tony at tcapp.com Tue Jan 27 15:14:10 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Jan 27 15:14:23 2004 Subject: [python-win32] Re: Python-win32 Digest, Vol 10, Issue 25 In-Reply-To: Message-ID: <20040127120739.R2466-100000@yamato.yamato.com> > ------------------------------ > > Message: 5 > Date: Tue, 27 Jan 2004 10:52:41 -0000 > From: Tim Golden > Subject: RE: [python-win32] Object hierarchy for Windows > Desktop-Propertie s-Screensaver > To: python-win32@python.org > Message-ID: > > > Content-Type: text/plain; charset="iso-8859-1" > > >From: Tony Cappellini [mailto:tony@tcapp.com] > > > >I'm looking for a way to access the Screensaver Tab, under > >DEsktop-Properties, via Python > > > >There are no useable references to screensaver in this mailing > >list, and > >refernces to Desktop were not what I'm looking for. > > > > Tony. Do you really mean that you want to get programmatic > control of that tab in that window? Or do you mean that you > want access to the properties of the screensaver? I want to access the properties of the screensaver tab- that is, I want to be able to swicth screensavers from a python program, disable it, change the time before it becomes active, etc. I'll take a look at Simon's site to see if there is something i Can use. thanks From tim.golden at viacom-outdoor.co.uk Wed Jan 28 02:12:25 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Jan 28 02:20:41 2004 Subject: [python-win32] Re: Python-win32 Digest, Vol 10, Issue 25 Message-ID: >From: Tony Cappellini [mailto:tony@tcapp.com] >> From: Tim Golden >> >> >From: Tony Cappellini [mailto:tony@tcapp.com] >> > >> >I'm looking for a way to access the Screensaver Tab, under >> >DEsktop-Properties, via Python >> > >> >There are no useable references to screensaver in this mailing >> >list, and >> >refernces to Desktop were not what I'm looking for. >> > >> >> Tony. Do you really mean that you want to get programmatic >> control of that tab in that window? Or do you mean that you >> want access to the properties of the screensaver? > >I want to access the properties of the screensaver tab- that >is, I want to >be able to swicth screensavers from a python program, disable >it, change >the time before it becomes active, etc. >I'll take a look at Simon's site to see if there is something >i Can use. > >thanks > This recipe does something similar: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/106624 Some things (get/set timeout) you do via SystemParametersInfo: http://msdn.microsoft.com/library/en-us/sysinfo/base/systemparametersinfo.as p which you could access via ctypes. (There are a couple of examples around python-win32 and c.l.py). TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From rays at san.rr.com Wed Jan 28 22:17:10 2004 From: rays at san.rr.com (RJ) Date: Wed Jan 28 23:37:44 2004 Subject: [python-win32] problems integrating ultrasound (.exe server + ActiveX Control) in client application using win32com Message-ID: <5.2.1.1.2.20040128191005.05f5f370@pop-server.san.rr.com> Hi Frank, > I am trying to integrate medical ultrasound in a image guided surgery > application using win32com. > > The client application is supposed to initialize the streaming video > mechanism by calling methods on the If you can open your stream via one of the standard Windows vipcap applications, then the Python app I wrote which grabbs DirectShow video directly to Python buffers via StringIO would work. It captures 640x480 30fps to memory for my video astronomy app... Ray From rays at blue-cove.com Thu Jan 29 01:43:41 2004 From: rays at blue-cove.com (RayS) Date: Thu Jan 29 01:42:34 2004 Subject: [python-win32] problems integrating ultrasound (.exe server + ActiveX Control) in client application using win32com Message-ID: <5.2.1.1.2.20040128224334.0646d030@pop-server.san.rr.com> Hi Frank, > I am trying to integrate medical ultrasound in a image guided surgery > application using win32com. > > The client application is supposed to initialize the streaming video > mechanism by calling methods on the If you can open your stream via one of the standard Windows vipcap applications, then the Python app I wrote which grabbs DirectShow video directly to Python buffers via StringIO would work. It captures 640x480 30fps to memory for my video astronomy app... Ray From jesko at rs.fromadia.com Thu Jan 29 03:03:18 2004 From: jesko at rs.fromadia.com (=?iso-8859-1?Q?Jesko_H=FCttenhain?=) Date: Thu Jan 29 03:02:52 2004 Subject: [python-win32] win32 raw sockets problem Message-ID: Hey everyone. I have already successfully written tools that make use of raw sockets in Windows 2000, using C/C++. However, when trying to write similar code in python, I witnessed several problems. While it is possible to create a raw socket, bind it to any port and set the IP_HDRINCL option in C, this fails in python. In fact, when using either IPPROTO_RAW or IPPROTO_IP, it is either possible to have IP_HDRINCL set to 1 *OR* bind the socket. The first of both operations always succeeds, but the second will fail. Also, IP_HDRINCL was not defined, so I looked up the value in ws2tcpip.h (IP_HDRICNCL=2). First, I have been using IPPROTO_RAW and IPPROTO_IP - because I could bind the socket and unless I was unable to set the IP_HDRINCL option, I used ethereal to sniff my network traffic and sent a test packet. Actually, the data was put onto the wire correctly, but as expected, it was preceded by an IP header with a transport protocol field set to 0xFF or 0x00. Since I did not really need to construct the IP header myself but rather a couple of custom TCP packets, I just tried to call socket(AF_INET,SOCK_RAW,IPPROTO_TCP). Anyhow, I was neither able to bind this socket, nor could I send any data through it. I am certain that Windows 2000 itself and the available WinSock implementation are capable of creating the custom packets I need, because I already implemented an appropriate program in C. Nevertheless, I was unable to find the problem in socketmodule.c as it uses the standard socket() call just like the C program I wrote. I also did some research through google, but could not find any further information about python/raw sockets/win32 at all. Thus, if you know any possible solution for this problem or if you could simply provide some further information or resources / links, I would be very thankful. Thanks in advance, best regards Jesko Huettenhain From rays at blue-cove.com Thu Jan 29 16:48:57 2004 From: rays at blue-cove.com (Ray Schumacher) Date: Thu Jan 29 16:50:30 2004 Subject: [python-win32] Help with: pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)? Message-ID: <5.2.0.4.0.20040129134420.01e71ab8@blue-cove.com> >>> from win32com.client import * >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") >>> util >>> # pop-up, no args ... util.AboutBox() Traceback (most recent call last): File "", line 2, in ? File "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00 C0DF2247CAx0x3x5.py", line 34, in AboutBox return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),) pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) So, the util class Dispatches, but _all_ calls (properties and functions) give 'Catastrophic failure' Is this really some sort of types problem with this OCX? Thanks for any and all help, Ray Test run below, kitchen sink included: C:\projects\CV-Mini>python Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from win32com.client import * >>> util = gencache._GetModule('8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5') >>> gencache.GetGeneratedFileName('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA',0,3,5) 'AA34F82-95C9-11D3-8EB6-00C0DF2247Cx0x3x5' >>> gencache.MakeModuleForTypelib('8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5',0 ,3,5) >>> gencache.GetModuleForCLSID('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA') >>> gencache.GetClassForCLSID('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA') >>> gencache.GetModuleForProgID('EDREUTLX.EDREUtlXCtrl.1') >>> gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5) >>> gencache.EnsureModule('EDREUTLX.EDREUtlXCtrl.1',0,3,5) >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") >>> util >>> gencache.EnsureDispatch(util) >>> >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") >>> util >>> # pop-up, no args ... util.AboutBox() Traceback (most recent call last): File "", line 2, in ? File "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00 C0DF2247CAx0x3x5.py", line 34, in AboutBox return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),) pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) >>> # a property ... util.Version Traceback (most recent call last): File "", line 2, in ? File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 451, in __getattr__ return self._ApplyTypes_(*args) File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 445, in _ApplyTypes_ return self._get_good_object_(self._oleobj_.InvokeTypes(*((dispid, 0, wFlags , retType, argTypes) + args)), user, resultCLSID) pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) >>> From rays at san.rr.com Thu Jan 29 22:57:07 2004 From: rays at san.rr.com (RJ) Date: Thu Jan 29 22:56:01 2004 Subject: [python-win32] problems integrating ultrasound (.exe server + ActiveX Control) in client application using win32com In-Reply-To: <5.2.0.4.2.20040129120941.044202d8@blue-cove.com> References: <4E3F272B-5289-11D8-BBBC-000A95864E24@sintef.no> <5.2.1.1.2.20040128224334.0646d030@pop-server.san.rr.com> Message-ID: <5.2.1.1.2.20040129193958.02fbd020@pop-server.san.rr.com> Hi Frank, Are you using an OCX and win32com? I'm having issues with an A/D driver... >>If this is the case would it be possible to try your code? I've posted all of the Python video capture code relevant to frame grabbers I have at: http://rjs.org/astro/1004x/Python/ PyCam1.pyw PyDShowCam.dll PyDrawDib.dll are the DirectShow capture stuff you'll want to look at Some of the code is not mine, but some is also no longer available on the web... CAP7.PY my astro app CAP7X.PY ditto... PyCam.pyw app from a Canadian machine vision guy PyCam1.pyw same as above PyDShowCam.dll same as above PyDrawDib.dll same as above PyWiewSrc.zip image manip. program UUSCAM2.PY vid capture by a USB driver UUSGPIB2.PY vid capture by a USB driver VIDCAP.PYD ? forgot _IMAGING.PYD ? boa.zip Boa Constructor 0.2.8 capture.py my old VFW astro app capture4.py my old VFW astro app image_view-1.0beta1.zip ? imagery/ port.py test script from printer port usbpicwt2.py vid capture by a USB driver wxPyPlot.py I modded this plot module slightly >>Do you know of any other python-api for frame grabbing? > >http://videocapture.sourceforge.net/ >It won't do 640x480 at 30fps on my machine, but I use a Cereron 300. It >also uses VFW. ^ This is Markus Gritsch's capture module for VFW, my first app used it. >Also, read this thread from PIL >http://mail.python.org/pipermail/image-sig/2002-February/001732.html Let me know if you derive new, useful stuff! Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040129/badc143a/attachment.html From rays at blue-cove.com Thu Jan 29 22:57:30 2004 From: rays at blue-cove.com (RayS) Date: Thu Jan 29 22:56:44 2004 Subject: [python-win32] problems integrating ultrasound (.exe server + ActiveX Control) in client application using win32com Message-ID: <5.2.1.1.2.20040129195718.03249070@pop-server.san.rr.com> Hi Frank, Are you using an OCX and win32com? I'm having issues with an A/D driver... >>If this is the case would it be possible to try your code? I've posted all of the Python video capture code relevant to frame grabbers I have at: http://rjs.org/astro/1004x/Python/ PyCam1.pyw PyDShowCam.dll PyDrawDib.dll are the DirectShow capture stuff you'll want to look at Some of the code is not mine, but some is also no longer available on the web... CAP7.PY my astro app CAP7X.PY ditto... PyCam.pyw app from a Canadian machine vision guy PyCam1.pyw same as above PyDShowCam.dll same as above PyDrawDib.dll same as above PyWiewSrc.zip image manip. program UUSCAM2.PY vid capture by a USB driver UUSGPIB2.PY vid capture by a USB driver VIDCAP.PYD ? forgot _IMAGING.PYD ? boa.zip Boa Constructor 0.2.8 capture.py my old VFW astro app capture4.py my old VFW astro app image_view-1.0beta1.zip ? imagery/ port.py test script from printer port usbpicwt2.py vid capture by a USB driver wxPyPlot.py I modded this plot module slightly >>Do you know of any other python-api for frame grabbing? > >http://videocapture.sourceforge.net/ >It won't do 640x480 at 30fps on my machine, but I use a Cereron 300. It >also uses VFW. ^ This is Markus Gritsch's capture module for VFW, my first app used it. >Also, read this thread from PIL >http://mail.python.org/pipermail/image-sig/2002-February/001732.html Let me know if you derive new, useful stuff! Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040129/9667abdb/attachment.html From rays at blue-cove.com Thu Jan 29 23:16:26 2004 From: rays at blue-cove.com (RayS) Date: Thu Jan 29 23:15:24 2004 Subject: [python-win32] RE: win32com - .ocx won't Dispatch... In-Reply-To: <20040130022038.95F884CC5C@swiper.ppgrp.ca> References: <5.2.0.4.0.20040129150323.02153d78@blue-cove.com> Message-ID: <5.2.1.1.2.20040129200134.0326a6b0@216.122.242.54> Thanks heaps Mark, it's too bad, because I'm also having a different problem with the DLL interface, which is why I'm trying the OCX... It's a commercial product, so hopefully I can convince them to support Python as well as C, VB etc. It may be just a matter of them compiling the OCX with different settings in MSVS (which is mostly black magic to me). At 09:23 PM 1/29/04 -0500, you wrote: >Well, Im sorry but I dont think I can be much help. I found and >downloaded the .ocx files, and tried this myself with the same >results. The closest thing I could find on Google was: > >http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=7049ba55.0106080434.1bcbc8d2%40posting.google.com&rnum=3&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26q%3Dpythoncom%2Bcatastrophic%2Bfailure%26sa%3DN%26tab%3Dwg I had only seen one other reference to "Catasrophic failure" myself >For what its worth I am struggling with a partially implemented COM server >myself and it doesnt work 100% either but at least I can work around it. Good luck, and thanks again Ray >From: Ray Schumacher [mailto:rays@blue-cove.com] >Sent: January 29, 2004 6:04 PM >To: markm@digitalwizardry.ca >Subject: Re: win32com - .ocx won't Dispatch... > > > >Thanks Markus, > >At 01:53 PM 1/29/2004, Markus Wankus wrote: > >Well - I have never seen "Catastrophic failure" before - but I have fought >with win32com and know how frustrating it can be. Also - I am NOT a COM >guru - more of a trial and error guru ;o). > > >I'm a Jack-of-all-master-of-none Guru... > > >Try the following: > >edr_mod = >gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5) > > >edr_obj = >Dispatch("EDREUTLX.EDREUtlXCtrl.1") > > >edr_obj.AboutBox() > > >>> from win32com.client import * > >>> edr_mod = > gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5) > >>> edr_obj = Dispatch("EDREUTLX.EDREUtlXCtrl.1") > >>> edr_obj.AboutBox >Control._DEDREUtlX instance at 0x10542896>> > >>> edr_obj.AboutBox() >Traceback (most recent call last): > File "", line 1, in ? > File > "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5.py", > line 34, in AboutBox > return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),) >pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) > >Yep, the same. It sees the methods but fails when requesting them or >properties. >A capture of the Python com Browser is attached, as well as the .py... > >Thanks for your help, I did see one other post via Google about the issue, >but it was not resolved. >Ray > > > >From: Ray Schumacher > >To: Markus Wankus , python-list@python.org > >Subject: Re: win32com - .ocx won't Dispatch... > >Date: Thu, 29 Jan 2004 13:44:09 -0800 > > > >At 12:12 PM 1/29/2004, Markus Wankus wrote: > > >Open the gen_py'd file 8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5.py, > and do some searching. You should be able to find an obvious main class > related to what you are doing (I'm not sure what the .tlb is), and it > will say in the comment or docstring that it is a ".", or whatever. > > > >Thanks Markus, > > > >The lines are from CoClassBaseClass: > >... > ># This CoClass is known by the name 'EDREUTLX.EDREUtlXCtrl.1' > >class EDREUtlX(CoClassBaseClass): # A CoClass > >... > >That would be a helpful bit for the docs! > > > >So, the util class Dispatches, but all calls (properties and functions) > give 'Catastrophic failure' > >Is this really some sort of types problem with this OCX? > >"pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)" > > > >Thanks for the help, > >Ray > > > >Test run below, kitchen sink included: > > > >C:\projects\CV-Mini>python > >Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on > win32 > >Type "help", "copyright", "credits" or "license" for more information. > > >>> from win32com.client import * > > >>> util = > gencache._GetModule('8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5') > > >>> > gencache.GetGeneratedFileName('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA',0,3,5) > >'AA34F82-95C9-11D3-8EB6-00C0DF2247Cx0x3x5' > > >>> > gencache.MakeModuleForTypelib('8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5',0 > >,3,5) > > >>> gencache.GetModuleForCLSID('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA') > > >>> gencache.GetClassForCLSID('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA') > > >>> gencache.GetModuleForProgID('EDREUTLX.EDREUtlXCtrl.1') > > > > >>> gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5) > > > > >>> gencache.EnsureModule('EDREUTLX.EDREUtlXCtrl.1',0,3,5) > > >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") > > >>> util > > > > >>> gencache.EnsureDispatch(util) > > > > >>> > > >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") > > >>> util > > > > >>> # pop-up, no args > >... util.AboutBox() > >Traceback (most recent call last): > > File "", line 2, in ? > > File > "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00 > >C0DF2247CAx0x3x5.py", line 34, in AboutBox > > return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),) > >pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) > > >>> # a property > >... util.Version > >Traceback (most recent call last): > > File "", line 2, in ? > > File "C:\Python23\lib\site-packages\win32com\client\__init__.py", > line 451, in > > __getattr__ > > return self._ApplyTypes_(*args) > > File "C:\Python23\lib\site-packages\win32com\client\__init__.py", > line 445, in > > _ApplyTypes_ > > return self._get_good_object_(self._oleobj_.InvokeTypes(*((dispid, > 0, wFlags > >, retType, argTypes) + args)), user, resultCLSID) > >pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) > > >>> > > > > > >---------- >The new MSN 8: smart spam protection >and 2 months FREE* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040129/e72b7689/attachment-0001.html From theller at python.net Fri Jan 30 02:50:02 2004 From: theller at python.net (Thomas Heller) Date: Fri Jan 30 02:50:18 2004 Subject: [python-win32] Re: Help with: pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)? References: <5.2.0.4.0.20040129134420.01e71ab8@blue-cove.com> Message-ID: Ray Schumacher writes: >>>> from win32com.client import * >>>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") >>>> util > >>>> # pop-up, no args > ... util.AboutBox() > Traceback (most recent call last): > File "", line 2, in ? > File "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00 > C0DF2247CAx0x3x5.py", line 34, in AboutBox > return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),) > pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) > > So, the util class Dispatches, but _all_ calls (properties and > functions) give 'Catastrophic failure' Is this really some sort of > types problem with this OCX? Can it be that the ocx isn't correctly initialized? Maybe it only works if hosted in a real activeX container? You could try to search for help in an atl group... Thomas From lpritc at scri.sari.ac.uk Fri Jan 30 04:57:41 2004 From: lpritc at scri.sari.ac.uk (Leighton Pritchard) Date: Fri Jan 30 04:57:52 2004 Subject: [python-win32] Problems with py2exe on Biopython-based script Message-ID: <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.uk> Hi, I'm using Python 2.3 (Enthought distribution), py2exe 0.5, BioPython 1.23, and I have a script: ### gentest.py from Bio import GenBank gi_list = ['AF339445', 'AF339444', 'AF339443', 'AF339442', 'AF339441'] record_parser = GenBank.FeatureParser() # GenBank file parser ncbi_dict = GenBank.NCBIDictionary(parser = record_parser, database = "nucleotide") # Dict for accessing NCBI count = 1 for accession in gi_list: print "Accessing GenBank for %s... (%d/%d)" % (accession, count, len(gi_list)) try: record = ncbi_dict[accession] # Get record as SeqRecord RECORDS.append(record) # Put records in local list except: print "Accessing record %s failed" % accession count += 1 ### Which seems fairly simple and straightforward. However, when I try to turn this into a standalone executable with py2exe with the script below, the following problems occur: ### setup.py from distutils.core import setup import py2exe, sys setup (name = "genbank2excel", version = "0.10", url = r'http://bioinf.scri.sari.ac.uk/lp/index.shtml', author = "Leighton Pritchard", console = ["gentest.py"]) ### Problem 1: apparently missing modules [partial stdout from python setup.py py2exe] [...] *** copy dlls *** copying E:\APPLIC~1\PYTHON~2\lib\site-packages\py2exe\run.exe -> E:\Data\CVSWorkspace\genbank2excel\genbank2excel\dist\gentest.exe The following modules appear to be missing ['mindy', 'mxTextTools.__version__'] Problem 2: The compiled program doesn't seem to like the os.listdir call in Bio/__init__.py line 52 (55 here because of some exploratory debugging lines I inserted), and doesn't think that the Bio/config folder in the library.zip file that py2exe generates is a file or directory (tested with os.isdir and os.isfile)... [complete stderr traceback from running the resulting gentest.exe] Traceback (most recent call last): File "gentest.py", line 1, in ? File "Bio\__init__.pyc", line 68, in ? File "Bio\__init__.pyc", line 55, in _load_registries WindowsError: [Errno 3] The system cannot find the path specified: 'E:\\Data\\CVSWorkspace\\genbank2excel\\genbank2excel\\dist\\library.zip\\Bio\\config/*.*' Can any of you help or advise me on this? Am I missing something obvious? Thanks in advance, Dr Leighton Pritchard AMRSC D104, PPI, Scottish Crop Research Institute Invergowrie, Dundee, DD2 5DA, Scotland, UK E: lpritc@scri.sari.ac.uk T: +44 (0)1382 568579 F: +44 (0)1382 568578 PGP key FEFC205C: http://www.keyserver.net http://pgp.mit.edu From lpritc at scri.sari.ac.uk Fri Jan 30 06:53:25 2004 From: lpritc at scri.sari.ac.uk (Leighton Pritchard) Date: Fri Jan 30 06:53:33 2004 Subject: [python-win32] Problems with py2exe on Biopython-based script In-Reply-To: <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.u k> References: <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.uk> Message-ID: <6.0.1.1.0.20040130115254.01c9c598@exchange1.scri.sari.ac.uk> Hi, I have a workaround for this single build (all modifications are to BioPython), though it's not ideal. First, I replaced this line in Bio/__init__.py x = os.listdir( os.path.dirname(__import__("Bio.config", {}, {}, ["Bio"]).__file__)) with an explicit naming of each file in the library.zip file generated by py2exe x = ['.\\library.zip\\Bio\\config\\__init__.pyc', '.\\library.zip\\Bio\\config\\_support.pyc', '.\\library.zip\\Bio\\config\\FormatRegistry.pyc', '.\\library.zip\\Bio\\config\\Registry.pyc'] and this solved problem number 2 below. However, it introduced a new problem, in that FormatIO was trying to use a (nonexistent?) module - Bio.formats, so I substituted the lines (54, 55) import Bio registery = Bio.formats with import Bio.formatdefs registery = Bio.formatdefs and this worked. I then wrapped the original lines and their replacements in try: except: and this seems fine. The missing modules 'mindy' and 'mxTextTools.__version__' in problem 1 seem not to matter. At 09:57 30/01/2004, Leighton Pritchard wrote: >Hi, > >I'm using Python 2.3 (Enthought distribution), py2exe 0.5, BioPython 1.23, >and I have a script: > >### gentest.py > >from Bio import GenBank > >gi_list = ['AF339445', 'AF339444', 'AF339443', 'AF339442', 'AF339441'] >record_parser = GenBank.FeatureParser() # GenBank file parser >ncbi_dict = GenBank.NCBIDictionary(parser = record_parser, > database = "nucleotide") # Dict for > accessing NCBI > >count = 1 >for accession in gi_list: > print "Accessing GenBank for %s... (%d/%d)" % (accession, count, > len(gi_list)) > try: > record = ncbi_dict[accession] # Get record as SeqRecord > RECORDS.append(record) # Put records in local list > except: > print "Accessing record %s failed" % accession > count += 1 > >### > >Which seems fairly simple and straightforward. However, when I try to >turn this into a standalone executable with py2exe with the script below, >the following problems occur: > >### setup.py > >from distutils.core import setup >import py2exe, sys > >setup (name = "genbank2excel", > version = "0.10", > url = r'http://bioinf.scri.sari.ac.uk/lp/index.shtml', > author = "Leighton Pritchard", > console = ["gentest.py"]) > >### > >Problem 1: apparently missing modules > >[partial stdout from python setup.py py2exe] >[...] >*** copy dlls *** >copying E:\APPLIC~1\PYTHON~2\lib\site-packages\py2exe\run.exe -> >E:\Data\CVSWorkspace\genbank2excel\genbank2excel\dist\gentest.exe >The following modules appear to be missing >['mindy', 'mxTextTools.__version__'] > >Problem 2: The compiled program doesn't seem to like the os.listdir call >in Bio/__init__.py line 52 (55 here because of some exploratory debugging >lines I inserted), and doesn't think that the Bio/config folder in the >library.zip file that py2exe generates is a file or directory (tested with >os.isdir and os.isfile)... > >[complete stderr traceback from running the resulting gentest.exe] >Traceback (most recent call last): > File "gentest.py", line 1, in ? > File "Bio\__init__.pyc", line 68, in ? > File "Bio\__init__.pyc", line 55, in _load_registries >WindowsError: [Errno 3] The system cannot find the path specified: >'E:\\Data\\CVSWorkspace\\genbank2excel\\genbank2excel\\dist\\library.zip\\Bio\\config/*.*' > >Can any of you help or advise me on this? Am I missing something obvious? > >Thanks in advance, > >Dr Leighton Pritchard AMRSC >D104, PPI, Scottish Crop Research Institute >Invergowrie, Dundee, DD2 5DA, Scotland, UK >E: lpritc@scri.sari.ac.uk >T: +44 (0)1382 568579 F: +44 (0)1382 568578 >PGP key FEFC205C: http://www.keyserver.net http://pgp.mit.edu > > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > Dr Leighton Pritchard AMRSC D104, PPI, Scottish Crop Research Institute Invergowrie, Dundee, DD2 5DA, Scotland, UK E: lpritc@scri.sari.ac.uk T: +44 (0)1382 568579 F: +44 (0)1382 568578 PGP key FEFC205C: http://www.keyserver.net http://pgp.mit.edu From theller at python.net Fri Jan 30 07:45:06 2004 From: theller at python.net (Thomas Heller) Date: Fri Jan 30 07:45:45 2004 Subject: [python-win32] Re: Problems with py2exe on Biopython-based script References: <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.uk> <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.u k> <6.0.1.1.0.20040130115254.01c9c598@exchange1.scri.sari.ac.uk> Message-ID: <7jz9ehbh.fsf@python.net> Leighton Pritchard writes: >> I'm using Python 2.3 (Enthought distribution), py2exe 0.5, BioPython >> 1.23, and I have a script: >> >>### gentest.py >> >>from Bio import GenBank >> >>gi_list = ['AF339445', 'AF339444', 'AF339443', 'AF339442', 'AF339441'] >>record_parser = GenBank.FeatureParser() # GenBank file parser >>ncbi_dict = GenBank.NCBIDictionary(parser = record_parser, >> database = "nucleotide") # Dict >> for accessing NCBI >> >>count = 1 >>for accession in gi_list: >> print "Accessing GenBank for %s... (%d/%d)" % (accession, count, >> len(gi_list)) >> try: >> record = ncbi_dict[accession] # Get record as SeqRecord >> RECORDS.append(record) # Put records in local list >> except: >> print "Accessing record %s failed" % accession >> count += 1 >> >>### >> >> Which seems fairly simple and straightforward. However, when I try >> to turn this into a standalone executable with py2exe with the >> script below, the following problems occur: >> [later] > I have a workaround for this single build (all modifications are to > BioPython), though it's not ideal. > > First, I replaced this line in Bio/__init__.py > > x = os.listdir( > os.path.dirname(__import__("Bio.config", {}, {}, ["Bio"]).__file__)) > > with an explicit naming of each file in the library.zip file generated > by py2exe > > x = ['.\\library.zip\\Bio\\config\\__init__.pyc', > '.\\library.zip\\Bio\\config\\_support.pyc', > '.\\library.zip\\Bio\\config\\FormatRegistry.pyc', > '.\\library.zip\\Bio\\config\\Registry.pyc'] > > and this solved problem number 2 below. It might be possible to do this in a more general way. py2exe 0.5 uses the new import hooks (via the builtin zipimport hook), described in PEP 302. When a module is imported with this mechanism, Bio.config in this case, it gets a __loadler__ attribute. IIRC, this is an instance of the builtin zipimporter, and you may be able to get the list of files contained in the zip-archive that py2exe builds from it. Then you can probably replace the above code, which contains a hardcoded list. You could even test for the __loader__ attribute first, and trigger the special code only when it is present. This way you may end up with code that may be built into biopython's source code. The general rule with py2exe is: any code accessing the file system or using __import__ may create problems in the exe. > > However, it introduced a new problem, in that FormatIO was trying to > use a (nonexistent?) module - Bio.formats, so I substituted the lines > (54, 55) > > import Bio > registery = Bio.formats > > with > > import Bio.formatdefs > registery = Bio.formatdefs > > and this worked. >From a short inspection it seems that Bio.formats is set to an instance of Bio.config.FormatRegistry.FormatRegistry. FormatRegistry again contains code that calls __import__. py2exe (actually, modulefinder) finds needed modules by scanning the Python byte code for 'import' statements, it cannot find __import__ calls. So it may be needed for you to specify that the whole 'Bio' package must be included in the exe. Thomas From lpritc at scri.sari.ac.uk Fri Jan 30 09:47:11 2004 From: lpritc at scri.sari.ac.uk (Leighton Pritchard) Date: Fri Jan 30 09:53:58 2004 Subject: [python-win32] Re: Problems with py2exe on Biopython-based script In-Reply-To: <7jz9ehbh.fsf@python.net> References: <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.uk> <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.u k> <6.0.1.1.0.20040130115254.01c9c598@exchange1.scri.sari.ac.uk> <7jz9ehbh.fsf@python.net> Message-ID: <6.0.1.1.0.20040130134200.01cc1ec0@exchange1.scri.sari.ac.uk> Many thanks for the help, Thomas - I think my problem is solved with changes only to Bio/__init__.py; no modifications were required to FormatIO.py in the end. At 12:45 30/01/2004, Thomas Heller wrote: >It might be possible to do this in a more general way. [...] >When a module is imported with this mechanism, Bio.config in this case, >it gets a __loadler__ attribute. IIRC, this is an instance of the >builtin zipimporter, and you may be able to get the list of files >contained in the zip-archive that py2exe builds from it. [...] >You could even test for the __loader__ attribute first, and trigger the >special code only when it is present. [...] I've taken your advice, and replaced the original registry import code (lines 52-55) of Bio/__init__.py with the following: #### # Import code changed to allow for compilation with py2exe from distutils config_imports = __import__("Bio.config", {}, {}, ["Bio"]) # Import Bio.config if hasattr(config_imports, '__loader__'): # Is it in zipfile? zipfiles = __import__("Bio.config", {}, {}, ["Bio"]).__loader__._files x = [zipfiles[file][0] for file in zipfiles.keys() \ # Get only Bio.config modules if 'Bio\\config' in file] x = [name.split('\\')[-1] for name in x] # Get module name x = map(lambda x: x[:-4], x) # chop off '.pyc' else: # Not in zipfile, get files normally x = os.listdir( os.path.dirname(config_imports.__file__)) x = filter(lambda x: not x.startswith("_") and x.endswith(".py"), x) x = map(lambda x: x[:-3], x) # chop off '.py' ### Which seems to work. >The general rule with py2exe is: any code accessing the file system or >using __import__ may create problems in the exe. I appear to be finding this out the hard way > >From a short inspection it seems that Bio.formats is set to an instance >of Bio.config.FormatRegistry.FormatRegistry. FormatRegistry again >contains code that calls __import__. You're right - that was a great help in tracking down the second part of the above solution. Dr Leighton Pritchard AMRSC D104, PPI, Scottish Crop Research Institute Invergowrie, Dundee, DD2 5DA, Scotland, UK E: lpritc@scri.sari.ac.uk T: +44 (0)1382 568579 F: +44 (0)1382 568578 PGP key FEFC205C: http://www.keyserver.net http://pgp.mit.edu From theller at python.net Fri Jan 30 11:01:57 2004 From: theller at python.net (Thomas Heller) Date: Fri Jan 30 11:02:05 2004 Subject: [python-win32] Re: Problems with py2exe on Biopython-based script References: <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.uk> <6.0.1.1.0.20040130095550.01dbcff0@exchange1.scri.sari.ac.u k> <6.0.1.1.0.20040130115254.01c9c598@exchange1.scri.sari.ac.uk> <7jz9ehbh.fsf@python.net> <6.0.1.1.0.20040130134200.01cc1ec0@exchange1.scri.sari.ac.uk> Message-ID: Leighton Pritchard writes: > Many thanks for the help, Thomas - I think my problem is solved with > changes only to Bio/__init__.py; no modifications were required to > FormatIO.py in the end. > > I've taken your advice, and replaced the original registry import code > (lines 52-55) of Bio/__init__.py with the following: > > #### > > # Import code changed to allow for compilation with py2exe from distutils > config_imports = __import__("Bio.config", {}, {}, ["Bio"]) # > Import Bio.config > if hasattr(config_imports, '__loader__'): # Is > it in zipfile? > zipfiles = __import__("Bio.config", {}, {}, ["Bio"]).__loader__._files > x = [zipfiles[file][0] for file in zipfiles.keys() \ # Get > only Bio.config modules > if 'Bio\\config' in file] > x = [name.split('\\')[-1] for name in x] # Get > module name > x = map(lambda x: x[:-4], x) # > chop off '.pyc' > else: # Not in zipfile, get files normally > x = os.listdir( > os.path.dirname(config_imports.__file__)) > x = filter(lambda x: not x.startswith("_") and x.endswith(".py"), x) > x = map(lambda x: x[:-3], x) # chop off '.py' > > ### > > Which seems to work. You could suggest the biopython guys to change their code for the benfit of future users ;-) And, it would be most appreciated if you would create a page in the py2exe wiki outlining the principal problem and the solution: TIA, Thomas From spencer at efn.org Fri Jan 30 19:13:43 2004 From: spencer at efn.org (spencer@efn.org) Date: Fri Jan 30 19:13:48 2004 Subject: [python-win32] py2exe, wxPython, unwanted console Message-ID: <1075508023.401af337e55c0@webmail.efn.org> I'm a wxPython/py2exe newbie with experience writing generic Python. Now I want to create standalone GUI apps to run in Windows. I got a Hello World frame to run, but the black Windows console window flashes briefly on the screen before the Hello World frame appears. How do I make the console not appear at all? I'm running Python 2.3 in Windows 2000. ---------Here's my setup script-------------- # setup.py from distutils.core import setup import py2exe setup(console=["wxPy1.py"]) ----------Here's wxPy1.py--------------- from wxPython.wx import wxPySimpleApp, wxFrame app = wxPySimpleApp() frame = wxFrame(None, -1, "Hello World") frame.Show(1) app.MainLoop() ---------------------------------------------- From rays at blue-cove.com Fri Jan 30 20:55:20 2004 From: rays at blue-cove.com (RayS) Date: Fri Jan 30 20:54:08 2004 Subject: [python-win32] py2exe, wxPython, unwanted console In-Reply-To: <1075508023.401af337e55c0@webmail.efn.org> Message-ID: <5.2.1.1.2.20040130175318.068e7d90@216.122.242.54> At 04:13 PM 1/30/04 -0800, spencer@efn.org wrote: >I'm a wxPython/py2exe newbie with experience >writing generic Python. Now I want to create >standalone GUI apps to run in Windows. >I got a Hello World frame to run, but the black >Windows console window flashes briefly on the screen >before the Hello World frame appears. >How do I make the console not appear at all? Do you need a console? If not, just rename .py to.pyw, no console[] stuff. Ray From fredm at smartypantsco.com Thu Jan 29 20:52:59 2004 From: fredm at smartypantsco.com (Alfred Milgrom) Date: Fri Jan 30 20:55:31 2004 Subject: [python-win32] py2exe, wxPython, unwanted console In-Reply-To: <1075508023.401af337e55c0@webmail.efn.org> Message-ID: <5.1.0.14.0.20040130125109.039d0dd0@192.168.1.1> At 04:13 PM 30/01/04 -0800, spencer@efn.org wrote: >I'm a wxPython/py2exe newbie with experience >writing generic Python. Now I want to create >standalone GUI apps to run in Windows. >I got a Hello World frame to run, but the black >Windows console window flashes briefly on the screen >before the Hello World frame appears. >How do I make the console not appear at all? >I'm running Python 2.3 in Windows 2000. General solution seems to be to rename your program into a .pyw before making it standalone with py2exe. HTH Fred Milgrom From stefan_holmgren at msn.com Sat Jan 31 17:44:07 2004 From: stefan_holmgren at msn.com (S.Holmgren) Date: Sat Jan 31 18:00:56 2004 Subject: [python-win32] Re: py2exe, wxPython, unwanted console In-Reply-To: <1075508023.401af337e55c0@webmail.efn.org> References: <1075508023.401af337e55c0@webmail.efn.org> Message-ID: spencer@efn.org wrote: > I'm a wxPython/py2exe newbie with experience > writing generic Python. Now I want to create > standalone GUI apps to run in Windows. > I got a Hello World frame to run, but the black > Windows console window flashes briefly on the screen > before the Hello World frame appears. > How do I make the console not appear at all? > I'm running Python 2.3 in Windows 2000. > > ---------Here's my setup script-------------- > # setup.py > from distutils.core import setup > import py2exe > > setup(console=["wxPy1.py"]) > > ----------Here's wxPy1.py--------------- > from wxPython.wx import wxPySimpleApp, wxFrame > app = wxPySimpleApp() > frame = wxFrame(None, -1, "Hello World") > frame.Show(1) > app.MainLoop() > > ---------------------------------------------- Change console to windows.....