[python-win32] PythonWin IDE: how to assign a function/code to key F1 etc. ?
want to put new functions (short python code) on keys like F1, F12, Ctrl-F1 and other keys. Is there a mechanism/recipe ? ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PythonWin IDE: how to assign a function/code to key F1 etc. ?
Mark Hammond wrote: Robert wrote: want to put new functions (short python code) on keys like F1, F12, Ctrl-F1 and other keys. Is there a mechanism/recipe ? Look for the *.cfg files in the pythonwin directory. Thanks. maybe some of the following stuff is useful for somebody, or for future PythonWin default: In attachment a patch for pywin/default.cfg, which does context (word) sensitive help from editor into Python Help and PythonWin Help F1 = HelpPy Ctrl+F1 = HelpPyWin .. and allows for faster edit-run cycle: running/interacting with (auto-unindented) selected code lines from editor Ctrl+K= Interact_SelectedLines Ctrl+E= ExecGlobal_SelectedLines ( the little patch of scintilla/config.py enables correct line numbers for traceback and debugging of code in default.cfg ) - Also CtrlEnter.patch (-> framework/interact.py), which enables ad-hoc debugging from interactive pane (Ctrl-Enter) into an interactive statement (without long-winded F5 running into breakpoints etc). I did not put the code into default.cfg, because a lot of pre-processing code is shared with normal interactive statement execution. Robert --- default.cfg.origTue Jul 01 00:54:06 2008 +++ default.cfg Thu Apr 30 17:01:29 2009 @@ -66,6 +66,16 @@ Ctrl+F3 = AutoFindNext +# Context Sensitive Help +F1 = HelpPy +Ctrl+F1 = HelpPyWin +Alt+F1 = HelpMSDN + +F12 = HelpWXIndex +Shift+F12= HelpWXPYIndex +Ctrl+F12 = HelpWXSearch +Alt+F12 = HelpWXNakedIndex +Ctrl+Shift+F12 = HelpWXNet [Keys:Editor] # Key bindings specific to the editor @@ -100,6 +110,10 @@ Shift+Subtract= FoldCollapseSecondLevel Multiply = FoldTopLevel +# Interact with selected lines +Ctrl+K= Interact_SelectedLines +Ctrl+E= ExecGlobal_SelectedLines + [Keys:Interactive] # Key bindings specific to the interactive window. # History for the interactive window @@ -213,3 +227,182 @@ # Almost an "unbind" - allows Pythonwin/MFC to handle the keystroke return 1 + +# Context Help + +def HelpPy(editor_window, event): +CtxHelp(editor_window, event, doc_ix=0) +def HelpPyWin(editor_window, event): +CtxHelp(editor_window, event, doc_ix=1) +def HelpMSDN(editor_window, event): +CtxHelp(editor_window, event, doc_ix=2) + +def HelpWXIndex(editor_window, event): +CtxHelp(editor_window, event, doc_ix=10) +def HelpWXSearch(editor_window, event): +CtxHelp(editor_window, event, doc_ix=11) +def HelpWXNakedIndex(editor_window, event): +CtxHelp(editor_window, event, doc_ix=12) +def HelpWXPYIndex(editor_window, event): +CtxHelp(editor_window, event, doc_ix=13) +def HelpWXNet(editor_window, event): +CtxHelp(editor_window, event, doc_ix=14) + +def CtxHelp(editor_window,event,doc_ix=0): + """ context sensitive help for (relevant) word near cursor position + """ + import sys,os,re,pywin,traceback + self=editor_window.edit + + # compute the relevant word .. + start,end=self.GetSel() + iline=self.LineFromChar(start) + line=self.GetLine(iline) + linestart=self.LineIndex(iline) + x=start-linestart + ix=0 + word="" + m=1 + while m: + m=re.search(r"\b\w+",line[ix:]) + if m: + if m.start()+ix>x: + break + ix+=m.end() + ww=m.group() + if re.match(r"\d+",ww): + continue + if ww in ("and","or","if","else","self","this",): + continue + word=ww + + # fork into help files / web .. + if word: + import win32help + import regutil + if doc_ix==0: # F1 + hf = regutil.GetRegisteredHelpFile("Main Python Documentation") + win32help.HtmlHelp(0, hf, win32help.HH_DISPLAY_INDEX, word) + elif doc_ix==1: # Ctrl-F1 + hf = regutil.GetRegisteredHelpFile("Pythonwin Reference") + win32help.HtmlHelp(0, hf, win32help.HH_DISPLAY_INDEX, word) + elif doc_ix==2: # + hf = regutil.GetRegisteredHelpFile("MSDN") +## if not os.path.exists(hf or ""): +## hf=os.environ.get('ProgramFiles') + r"\Microsoft Visual Studio\MSDN98\98VSa\1033\msdnvs6a.col" + if not os.path.exists(hf): + os.startfile("http://social.msdn.microsoft.com/Search/en-US/?Query=%s"; % word) +
Re: [python-win32] Modify only the first line of a big file (Roughly 1.5MB - For thousands of file).
Khalid Moulfi wrote: Hi all, I have thousands of file and I must update only the first line. My concern is : is it possible to read only the first line for each of these files and update the first line only without reading the file completely ? Version of Python is 2.2.1 Thanks for any help, when the length of the line/initial bytes doesn't change (by means of enough balancing spaces or so) you can open the file in "r+" mode and overwrite sections; e.g. after reading some bytes/line or so do f.seek(0) and overwrite the initial bytes. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] SetSystemTime: A required privilege is not held by the client
Tim Golden wrote: Robert wrote: SetSystemTime on Vista admin account throws: (1314, 'SetSystemTime', 'A required privilege is not held by the client.') Not known from previous Windows versions. With what switch or whatever can this be enabled? According to the docs: (warning: URL will self-destruct in two months) http://msdn2.microsoft.com/en-us/library/ms724942(VS.85).aspx this operation automatically enables the SE_SYSTEMTIME_NAME priv which is disabled by default. But if your user doesn't *have* the priv to start with, it won't be enabled and you'll get the error message above. I don't run Vista, but I assume it has some kind of user-management user interface? Find whatever bit of that deals with privileges (*not* groups) and add this priv to the user in question. does anybody with Vista know if there is a UI tool for setting this SE_SYSTEMTIME_NAME privilege in an account - how ? Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] File Time: win32file vs Python ?
>>> os.path.getmtime('x.txt') 1193160881 >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) 1193153681 >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - os.path.getmtime('x.txt') -7200 (Win XP) is this a bug, or is there a issue with timezones/summer time? aren't time.time() values absolute? R ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] File Time: win32file vs Python ?
Tim Roberts wrote: Robert wrote: os.path.getmtime('x.txt') 1193160881 int(win32file.GetFileAttributesExW('x.txt')[-2]) 1193153681 int(win32file.GetFileAttributesExW('x.txt')[-2]) - os.path.getmtime('x.txt') -7200 (Win XP) is this a bug, or is there a issue with timezones/summer time? aren't time.time() values absolute? The meaning of time.time isn't really relevant to this. GetFileAttributesExW returns values directly from the file system, and NTFS happens to store its timestamps in UTC. os.path.getmtime adjusts to local time. FAT file systems record timestamps in local time, which causes the reported times to change during summer time. hmm.. here os.path.getmtime() delivers exactly time.time() without any shift (NTFS) >>> open('x.txt','w').close(); time.time(); os.path.getmtime('x.txt'); int(win32file.GetFileAttributesExW('x.txt')[-2]) 1246618638.25 1246618638.25 1246611438 and win32file/int(PyTime)has the -7200 time.altzone on it. Guess it doesn't make sense. Seems PyTime internally forces to "wall clock digits" only and __int__ doesn't even respect altzone. Guess int-time values should never have local/summer on it? - (unless info is missing like on FAT.) R ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] File Time: win32file vs Python ?
time.time() / getmtime() is absolute / UTC. and win32file says: compatible with time.time. a int value doesn't make sense as localtime? It even picks up daylight saving, so the int file times would change in winter >>> time.timezone -3600 >>> time.altzone -7200 R Paul Koning wrote: Maybe one is defined to return local time while the other returns the time value as UTC? I don't have the docs, but they should tell... paul -Original Message- From: python-win32-bounces+pkoning=equallogic@python.org [mailto:python-win32-bounces+pkoning=equallogic....@python.org] On Behalf Of Robert Sent: Thursday, July 02, 2009 5:07 PM To: python-win32@python.org Subject: [python-win32] File Time: win32file vs Python ? >>> os.path.getmtime('x.txt') 1193160881 >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) 1193153681 >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - os.path.getmtime('x.txt') -7200 (Win XP) is this a bug, or is there a issue with timezones/summer time? aren't time.time() values absolute? R ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] File Time: win32file vs Python ?
Dave Angel wrote: Tim Roberts wrote: Robert wrote: os.path.getmtime('x.txt') 1193160881 int(win32file.GetFileAttributesExW('x.txt')[-2]) 1193153681 int(win32file.GetFileAttributesExW('x.txt')[-2]) - os.path.getmtime('x.txt') -7200 (Win XP) is this a bug, or is there a issue with timezones/summer time? aren't time.time() values absolute? The meaning of time.time isn't really relevant to this. GetFileAttributesExW returns values directly from the file system, and NTFS happens to store its timestamps in UTC. os.path.getmtime adjusts to local time. FAT file systems record timestamps in local time, which causes the reported times to change during summer time. That's part of the explanation. That explains why the symptom doesn't show up on FAT systems, but not what the symptom is really about. When converting UCT to local time, there are two reasonable algorithms. For most people, one of them makes sense, so the other sounds like a bug. But people are very split as to which one is the "right" one. If you're converting the current time to local, it seems logical that you'd add the timezone offset, adjust for daylight-savings if it's "summer," and be done. And if two people do it in two different time zones they'd get different answers for "now." Likewise if one of them is in a state or country that doesn't honor dst, they'd be off by an hour. But what's the "right" answer for a file timestamp, or for any other historical date/time? If the file (on a laptop, NTFS, say) was created in California, and being examined in Maine a few months later, you'd expect that the Maine time zone would be used. After all, the file system doesn't store the fact that the laptop happened to be in California when the file was created. But what about the dst (daylight-savings) conversion? That's the problem. One philosophy says it should be the dst state that was in effect at the time the file was created, while the other applies the dst state at the time of the conversion. If I recall correctly, getmtime() uses the first approach, while GetFileAttributesExW() (and DIR) use the second. The net effect of this is that if last winter you created a file at 3pm, and you have NOT changed time zones, then when you look at that file now with GetFileAttributesExW() it'll tell you it was created at 4pm. Notice that remote file access can complicate this, as can programs that store the time stamp in local time. I ran into this problem many years ago when saving digests of files to later check for corruption. I suspect you'd have the same problem when restoring a file from CD, if daylight savings time has changed. It's time stamp would be recreated wrong. Similarly zip files or other archives. I've even run into something similar on a FAT drive, when I ran across a file that was created during the "impossible" time each spring between 2 and 3am on dst-day. Well I think, the integer time does/should generally aim at a absolute value as good as possible - time.time() and os.path.getmtime() seem to do. Nothing with local/dst. No problem, no loss of information (e.g. on NTFS). Even the term "UTC" doesn't make sense so far ( except for defining *verbally* the absolute start point 1.1.1970 XX:XX UTC ) http://msdn.microsoft.com/en-us/library/ms724290(VS.85).aspx "A file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC). The system records file times when applications create, access, and write to files." -> just a fix offset to Python time.time() Guess this is wrong in win32file; or win32file looses info by early conversion to digits. "local/timezone/dst.." just makes sense for display values: "wall clock digits". When info is missing in time stamps / digits stored, like with FAT time stamps, then only the question arises, which assumptions to make on int-conversion - UTC/local time zone, or even DST. In that case its necessary to know (by an additional flag/attribute the assumption) R ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] win32com IE OnBeforeNavigate2: How to Cancel?
class MyWebBrowser(activex.Control, WebBrowserModule.WebBrowser): def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel): ... Cancel is a simple Python bool. Unlike in MFC CHtmlView::OnBeforeNavigate2 I cannot send a value back by ref this way. How to cancel the navigation? Robert - This member function is called by the framework to cause an event to fire before a navigation occurs in the web browser. virtual void OnBeforeNavigate2( LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel ); ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] win32com IE OnBeforeNavigate2: How to Cancel?
oh, found I have to return a 7-tuple with Cancel as last one return None, None, None, None, None, None, args.Cancel Robert wrote: class MyWebBrowser(activex.Control, WebBrowserModule.WebBrowser): def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel): ... Cancel is a simple Python bool. Unlike in MFC CHtmlView::OnBeforeNavigate2 I cannot send a value back by ref this way. How to cancel the navigation? Robert - This member function is called by the framework to cause an event to fire before a navigation occurs in the web browser. virtual void OnBeforeNavigate2( LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel ); ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] COM: Volume Shadow Service through Python?
is there a way to use the VSS (as requester) from Python rather simple way - with COM functions or so (win32com or cytpes)? or only through a compiled SWIG extension or so? CreateVssBackupComponents / vssapi.dll http://msdn.microsoft.com/en-us/library/aa381517(VS.85).aspx seems to be a C++ only interface. There is a "VSS.VSSCoordinator" in the COM browser. does it have to do anything with that... Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] COM: Volume Shadow Service through Python?
Kevin Horn wrote: On Mon, Mar 15, 2010 at 1:01 PM, Robert mailto:kxrobe...@googlemail.com>> wrote: is there a way to use the VSS (as requester) from Python rather simple way - with COM functions or so (win32com or cytpes)? or only through a compiled SWIG extension or so? CreateVssBackupComponents / vssapi.dll http://msdn.microsoft.com/en-us/library/aa381517(VS.85).aspx <http://msdn.microsoft.com/en-us/library/aa381517%28VS.85%29.aspx> seems to be a C++ only interface. There is a "VSS.VSSCoordinator" in the COM browser. does it have to do anything with that... Robert Search the list archives..there was something on this a while ago, but I can't find it just now... hmm "volume shadow" site:mail.python.org etc tells nothing. (Somebody just suggested to switch to VSS for some task). any other search terms associated with those posts? Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] os.stat() : files without "date modified" : OSError: [errno 22] Invalid Argument
on a users machine there are files which show no time stamp in "date modified" in Windows Explorer. Right on such files os.stat() crashes with "OSError: [errno 22] Invalid Argument". how can such files exist? and how to create such files programmatically for a test? what is the underlying cause for the crash? Best, Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] PyGUI blobedit creashes with pywin32-214 but not 212 - traceback - related problems
A) What could be the cause for this exception of PyGUI with pywin32-build214 - but not with build 212 :? Traceback (most recent call last): File "blobedit.py", line 131, in BlobApp().run() File "C:\Python26\lib\site-packages\GUI\GenericGApplications.py", line 122, in run self.process_args(sys.argv[1:]) File "C:\Python26\lib\site-packages\GUI\Generic\GApplications.py", line 251, in process_args self.open_app() File "blobedit.py", line 32, in open_app self.new_cmd() File "C:\Python26\lib\site-packages\GUI\Generic\GApplications.py", line 219, in new_cmd self.make_window(doc) File "blobedit.py", line 40, in make_window cursor = self.blob_cursor) File "C:\Python26\lib\site-packages\GUI\Win32\ScrollableViews.py", line 32, in __init__ GScrollableView.__init__(self, _win = win) win32ui.error: The object has been destroyed. class ScrollableView(GScrollableView): _line_scroll_amount = default_line_scroll_amount def __init__(self, **kwds): kwds.setdefault('extent', default_extent) win = ui.CreateView(win_dummy_doc) win.CreateWindow(win_none, 0, win_style, (0, 0, 100, 100)) GScrollableView.__init__(self, _win = win) self.set(**kwds) def get_hscrolling(self): ( both from commandline and inside PythonwinIDE ) === Maybe it has also to do with the following serious bugs (which can be worked around - but smelling): B) a oneliner with just "import wx" crashes hard with F5 in Pythonwin IDE build 214/py2.6 - but not in build 212 (ntdll.dll) AppName: pythonwin.exe AppVer: 2.6.214.0 ModName: ntdll.dll ModVer: 5.1.2600.3520Offset: 00044872 Code: 0xc015000f Address: 0x7c954872 (wxpython 2.8.11.0 (msw-unicode)) Only after this patch below (passing the SendMessage by a direct python call) it works again. (But with importing this oneliner file with Ctrl-I the IDE still crashes the same.) --- scintilla/bindings.py Sun Jan 04 15:01:18 2009 +++ scintilla/bindings.py Tue Oct 19 18:53:49 2010 @@ -33,7 +33,11 @@ def __init__(self, cmd): self.cmd = cmd def __call__(self, *args): - win32ui.GetMainFrame().SendMessage(win32con.WM_COMMAND, self.cmd) + # F5-run on simple "import wx" (wx2.8.11.0 (msw-unicode)) crashed in ntdll.dll: + ##win32ui.GetMainFrame().SendMessage(win32con.WM_COMMAND, self.cmd) + win32ui.GetMainFrame().OnCommand(self.cmd, 0) + #note: Ctrl-I/import still crashes because of WM_COMMAND in the line + C) all standalone win32ui GUI apps here crash hard with py2.3/pywin32-build214 at the very end/exit when they are executed from commandline "python somewin32uiapp.py". not with 212 and before. (they may crash as well as .pyw / win-apps - or even PythonWin.exe may crash at the end but nobody sees without a shell win) It seems, rude C-level leaks went into win32ui during 212 -> 214 - maybe because of the rework for py3k. Or is it all about one leak? 214 ui is hardly usable anywhere with various python versions - most practical use cases in and around win32ui become questionable. Yet there was no update for long time. I wonder that there are not many pywin32 bug reports in that direction. I only found : bug #2846720 (similar to C) ) and #2908939 perhaps. (->comments by M. Hammond, but no solution found) #3013558 Any ideas? Robert import wx ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] and PyGUI notes - Re: PyGUI blobedit creashes with pywin32-214 but not 212 - traceback - related problems
Roger Upole wrote: "Greg Ewing" wrote in message news:4cbfa5e9.7090...@canterbury.ac.nz... On 21/10/10 14:02, Roger Upole wrote: The problem stems from these 2 lines in ScrollableViews.py: rev = ui.CreateRichEditView() win_dummy_doc = rev.GetDocument() The win32ui framework really should not allow a view to be created without a valid document. Actually, the problem is that it *won't* allow a view to be created without a document, even though it should. If I remember correctly, at the MFC level, the constructor for the view object I'm using doesn't even take a Document as an argument -- you set it later if you want one. Win32ui goes out of its way to accept one at construction time. This wouldn't be such a serious problem, except that win32ui doesn't seem to provide any way of creating a Document without a resource -- hence the above kludge. You instantiate the MFC view object without a document, but in order to actually create a window and do anything useful with it, it needs a valid document. For some reason, the win32ui framework chooses to accept a document when the view is initially created instead of when its window is created. (That's where MFC accepts the associated document object.) I have yet to be able to determine where the dummy document is actually coming from in build 212. When I try to run it in a debug build, so many asserts are triggered that it would take forever to step thru it. The PyGUI framework can probably create a valid MFC document to use as a dummy with a little work. Something like: dt=win32ui.CreateDocTemplate(win32ui.IDR_PYTHONTYPE) win_dummy_doc=dt.DoCreateDoc() That may work if you run the program using the pythonwin executable, which contains the referenced resource. But I want pygui programs to be runnable using the standard Python interpreter, which means I can't rely on resources at all. The resource is actually in win32ui.pyd, rather than in Pythonwin itself. I've just verified that this method works from plain python.exe. The scrollable view test runs with this change. I should have written yesterday as I already found/worked on the doctemp problem yesterday, just I didn't completely solve (or better "workaround"), so I shifted .. (py2.6.5 / pywin32-214) A) in ScrollableViews.py globals: ##win_dummy_doc = ui.CreateRichEditView().GetDocument() doctemp = ui.CreateDocTemplate(ui.IDR_PYTHONTYPE) win_dummy_doc = doctemp.DoCreateDoc() #print "ScrollableViews: Created dummy doc" This lets start the blobedit.py / my test app. but at the exit hard crash. TestScrollableViews.py / 12-scroll.py crashes hard even at start (runtime to terminate in unusual...) B) in ScrollableViews.py globals: ##win_dummy_doc = ui.CreateRichEditView().GetDocument() #print "ScrollableViews: Created dummy doc" doctemp = ui.CreateDocTemplate(ui.IDR_PYTHONTYPE) import pywin.mfc.object doctemp = pywin.mfc.object.CmdTarget(doctemp) # otherwise we crash at exit win_dummy_doc = doctemp.DoCreateDoc() blobedit.py & 12-scroll.py now start, work and exit correct from commandline. (well the 12-scroll.py displays/user-interacts mostly buggy but thats not the problem here) However when I make multiple starts / close of the app-window in IDE/one process, or when in an app the total number of ScrollView's counts down to zero and then up again, then still a hard crash (somehow the doc is too smart and gets corrupt at zero count) C) the attached .patch : blobedit.py & 12-scroll.py now start, work and exit, and multi-boot, views count to zero and up again .. correct from commandline, python.exe & pythonw.exe & frozone with py2exe. D) But 39-text_editor.py with CRichEdit's (nothing to do with scrollview) and may test app with (scrollview +) richedits still crashes hard at exit when run with pythonw.exe (but not with python.exe !). I tried feeding in no-None RichEditDoc(templates) similar to scrollview .patch in dozends of ways, plus terminating, .close()ing docs/doctemps in various ways, but it didn't solve. I failed terribly. Maybe for such and similar reasons many apps crash at exit with 214. The (damn) Document/Template stuff in win32ui somehow seems to have become more instable in 214 (213?). danging pointers or so. (I often use ScrollViews, SplitterViews, RichEdits, etc. in win32ui apps - not wanting to use the damn MFC doc/view mechansim (pure Python is much better for this), just to exploit the Window features ... before in infinite time I rewrite the behavior of the MFC-goodies in pure win32gui ;-) ) Robert PS: PyGUI notes PyGUI is/seems a nice plan. rather direct on platform libs ( theorically - still damn MFC on Win ;-) ). If combined with a slim Mingw/msvcrt.dll complied Python ... But perhaps long time and debugging to get real world usability (Win). One could use the (bugfixed) existing behaviour, plus __geta
Re: [python-win32] PyGUI blobedit creashes with pywin32-214 but not 212 - traceback - related problems
Roger Upole wrote: "Robert" wrote in message news:i9kmoi$cl...@dough.gmane.org... B) a oneliner with just "import wx" crashes hard with F5 in Pythonwin IDE build 214/py2.6 - but not in build 212 (ntdll.dll) AppName: pythonwin.exe AppVer: 2.6.214.0 ModName: ntdll.dll ModVer: 5.1.2600.3520 Offset: 00044872 Code: 0xc015000f Address: 0x7c954872 (wxpython 2.8.11.0 (msw-unicode)) Only after this patch below (passing the SendMessage by a direct python call) it works again. (But with importing this oneliner file with Ctrl-I the IDE still crashes the same.) --- scintilla/bindings.py Sun Jan 04 15:01:18 2009 +++ scintilla/bindings.py Tue Oct 19 18:53:49 2010 @@ -33,7 +33,11 @@ def __init__(self, cmd): self.cmd = cmd def __call__(self, *args): - win32ui.GetMainFrame().SendMessage(win32con.WM_COMMAND, self.cmd) + # F5-run on simple "import wx" (wx2.8.11.0 (msw-unicode)) crashed in ntdll.dll: + ##win32ui.GetMainFrame().SendMessage(win32con.WM_COMMAND, self.cmd) + win32ui.GetMainFrame().OnCommand(self.cmd, 0) + #note: Ctrl-I/import still crashes because of WM_COMMAND in the line + Trying to run one GUI framework inside of another is a sure recipe for disaster. Both will be trying to process messages, with race conditions and memory conflicts galore. The short answer is "don't do that". I'm doing this since adam and eve with wx, win32ui and similar. When there was/is a little problem I first try flatten it. e.g. join the OnIdle or message translation. 2 or 3 things. Have seen people which edit code, save, start the GUI app , bug, exit , edit, start/test again .. With dynamic Python I edit code while it runs, objects/windows live; fumble, try, autocomplete on the living objects, sys.exepthook postmortem pywin debugger, set self=current_winthing_i_focus_on_for_a_while in the interactive , better autocompletion, Ctrl+Enter debug etc ... Even little reload code, exchange classes at runtime on big apps with big status ... reboot after 30x or so. Pythonwin is good therefor because of the joint thread. Its a feature not ... I think there is simply something not as good as it was in build 212. It may indicate/connect with deeper problems - like mentioned. And the problem is just about "import wx" at F5/Ctrl-I time. reproducible. no GUI start at all so far. the crash is not when doing "import wx" first in interactive, and then use F5 on a wx script... something with command handler status, GIL/reenter or so. Would be happy about any idea. Best Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] can't import dde module after importing win32ui
Mark Hammond wrote: On 7/06/2011 9:11 PM, nekolyanich wrote: Michel Claveau mclaveau.com> writes: Hi! I have also/another problem with win32ui in 216 version: on several COM's servers, if the line import win32ui is present, servers can not be contacted. If I comment the line, no more problem. Uncomment, problem is coming back. Waiting a solution, I come back to 214. @-salutations Saw this bug, and 214 version helped me with my 32-bit xp. But in production i'd have 64-bit mashine, and downgrading to 214 version don't helps. Any ideas, how to make it work? It will be something to do with the manifest and the mfc libraries. I think that even though the mfc dlls are installed with pywin32, it might not work as hoped :) Can you find a redistributable version of the MFC dlls you can try? I can't explain why the 32 vs 64bit versions behave differently other than what libraries are already installed. Sorry, not much help... same problem here. Well, the problem seems not to be 64bit specific. But is with build 216 and 215 on 32bit as well; and with all Python versions. Something changed critically with 215 build. The problem is not when starting through Pythinwin.exe (IDE), but only when starting with python(w).exe + win32ui (Even when the Pythonwin IDE is raise sucessfully through a script on python(w).exe, the problem is there) Is there a special manifest in Pythonwin.exe ? Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] can't import dde module after importing win32ui
Robert wrote: Mark Hammond wrote: It will be something to do with the manifest and the mfc libraries. I think that even though the mfc dlls are installed with pywin32, it might not work as hoped :) Can you find a redistributable version of the MFC dlls you can try? I can't explain why the 32 vs 64bit versions behave differently other than what libraries are already installed. Sorry, not much help... same problem here. Well, the problem seems not to be 64bit specific. But is with build 216 and 215 on 32bit as well; and with all Python versions. Something changed critically with 215 build. The problem is not when starting through Pythinwin.exe (IDE), but only when starting with python(w).exe + win32ui (Even when the Pythonwin IDE is raise sucessfully through a script on python(w).exe, the problem is there) Is there a special manifest in Pythonwin.exe ? notized: I remove just mfc90.dll from the Pythonwin folder, and then do python.exe: C:\Python26\Lib\site-packages\pythonwin>\python26\python Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32ui >>> win32ui.GetApp() object 'PyCWinApp' - assoc is 00BBC728, vi=, notify=0,ch/u=0/0 >>> import dde Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden. (module not found) >>> => dde relies on the mfc90.dll in the same folder, but win32ui(.GetApp()) not !? And: with that removed mfc90.dll I can yet start the Pythonwin.exe of that very same folder AND successfully import dde !: PythonWin 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> import dde >>> os.getcwd() 'C:\\Python26\\Lib\\site-packages\\pythonwin' >>> dde >>> => This time starting through Pythonwin.exe the same dde.pyd doesn't require the mfc90.dll in that folder! (I can even remove the other 3 mfc dlls too) => There is a strange mixup of mfc DLL dependencies, varying with the initial .exe There are also 2 different dates of the 4 MFC dlls here (in a very strange cross over order): 26.02.2011 18:4348.640 dde.pyd 04.11.2011 11:57 1.156.600 mfc90.dll 07.11.2007 02:19 1.162.744 mfc90u.dll 06.11.2007 23:5159.904 mfcm90.dll 04.11.2011 11:5759.904 mfcm90u.dll 04.11.2011 11:57 548 Microsoft.VC90.MFC.manifest 19.08.2010 14:56 354.304 pythoncom26.dll 26.02.2011 18:4319.968 Pythonwin.exe 19.08.2010 14:56 110.592 pywintypes26.dll 26.02.2011 18:42 778.240 win32ui.pyd 26.02.2011 18:4237.888 win32uiole.pyd 11 Datei(en) 3.789.332 Bytes 2 Verzeichnis(se), 43.639.382.016 Bytes frei I tried to copy various mfc90 DLL's (4 of same date; e.g. 18.4.2011) from WinSxS and also from pythonwin-212 to the 216 pythonwin folder , but that still didn't solve the dde import problem in 216 when starting through python(w).exe any ideas? Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] can't import dde module after importing win32ui
Robert wrote: Robert wrote: Mark Hammond wrote: It will be something to do with the manifest and the mfc libraries. I think that even though the mfc dlls are installed with pywin32, it might not work as hoped :) Can you find a redistributable version of the MFC dlls you can try? I can't explain why the 32 vs 64bit versions behave differently other than what libraries are already installed. Sorry, not much help... same problem here. Well, the problem seems not to be 64bit specific. But is with build 216 and 215 on 32bit as well; and with all Python versions. Something changed critically with 215 build. The problem is not when starting through Pythinwin.exe (IDE), but only when starting with python(w).exe + win32ui (Even when the Pythonwin IDE is raise sucessfully through a script on python(w).exe, the problem is there) Is there a special manifest in Pythonwin.exe ? notized: I remove just mfc90.dll from the Pythonwin folder, and then do python.exe: C:\Python26\Lib\site-packages\pythonwin>\python26\python Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32ui >>> win32ui.GetApp() object 'PyCWinApp' - assoc is 00BBC728, vi=, notify=0,ch/u=0/0 >>> import dde Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden. (module not found) >>> => dde relies on the mfc90.dll in the same folder, but win32ui(.GetApp()) not !? And: with that removed mfc90.dll I can yet start the Pythonwin.exe of that very same folder AND successfully import dde !: PythonWin 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> import dde >>> os.getcwd() 'C:\\Python26\\Lib\\site-packages\\pythonwin' >>> dde >>> => This time starting through Pythonwin.exe the same dde.pyd doesn't require the mfc90.dll in that folder! (I can even remove the other 3 mfc dlls too) => There is a strange mixup of mfc DLL dependencies, varying with the initial .exe There are also 2 different dates of the 4 MFC dlls here (in a very strange cross over order): 26.02.2011 18:43 48.640 dde.pyd 04.11.2011 11:57 1.156.600 mfc90.dll 07.11.2007 02:19 1.162.744 mfc90u.dll 06.11.2007 23:51 59.904 mfcm90.dll 04.11.2011 11:57 59.904 mfcm90u.dll 04.11.2011 11:57 548 Microsoft.VC90.MFC.manifest 19.08.2010 14:56 354.304 pythoncom26.dll 26.02.2011 18:43 19.968 Pythonwin.exe 19.08.2010 14:56 110.592 pywintypes26.dll 26.02.2011 18:42 778.240 win32ui.pyd 26.02.2011 18:42 37.888 win32uiole.pyd 11 Datei(en) 3.789.332 Bytes 2 Verzeichnis(se), 43.639.382.016 Bytes frei I tried to copy various mfc90 DLL's (4 of same date; e.g. 18.4.2011) from WinSxS and also from pythonwin-212 to the 216 pythonwin folder , but that still didn't solve the dde import problem in 216 when starting through python(w).exe any ideas? now I extracted the manifest from Pythonwin.exe with win32api.LoadResource(None, 24, 1) and saved it as python.exe.manifest (or myapp.exe.manifest) next to the used python.exe (-> see attachment) and then "import win32ui, dde" works with that python.exe ! Seen in 216: * win32ui.pyd has a internal manifest (extracted in attachment: contains only the MFC section) * dde.pyd doesn't have a internal manifest! In the pythonwin folder there is a Microsoft.VC90.MFC.manifest with matching version, though the local MFC DLLs and manifest seem not to be used at all now with that python.exe.manifest. and never were used with Pythonwin.exe. So how does this sort out? and how to explain this? Which MFC / manifest files should be packaged with a win32ui application binary. (py2exe doesn't collect that right directly) Robert PS: in C:\python26 is a update_manifest.py which adds a "Microsoft.Windows.Common-Controls" section to a local python.exe.manifest. Don't know if this is from 2.6.6 or from earlier python 2.6 versions, because the file is rather old. name="Microsoft.Windows.Common-Controls" version="6.0.0.0" well, what actually does this do? the presence of this manifest file/section makes a win32ui app look strange (background of labels etc.), and fatal: auto-magical button pressing is going on everywhere as soon as you move the mouse over a button or even without! what is this? (I've seen with a debug print: the HookCommand'ed handlers in those win32ui apps are called with strange big command notification codes - while true commands upon e.g. button pressing have a notification code of 0)
[python-win32] WinSxS, manifests and binary distribution ?
Hello, I want to see clearly which MFC DLLs (and VCR DLLs) pythonwin.exe or python(w).exe +win32ui.dll are actually using in Python2.6 or 2.7. And how to manage the actuall bindings/dependencies. And how to put together binary distribution files. I want to find a way to first move away the MFC DLLs, to have a situation here like on a computer without Python installed. And then put (& test) precisely the required DLLs/manifests next to a myapp.exe (win32ui based), so that I find which and how how files can be distributed. But the situation seems weired so far: Python2.7.2 / pywin 216: Verzeichnis von C:\Python27\Lib\site-packages\pythonwin 07.11.2011 14:44 . 07.11.2011 14:44 .. 26.02.2011 19:1048.640 dde.pyd 11.06.2008 13:02 1.550 license.txt 07.11.2007 03:19 1.156.600 mfc90.dll 07.11.2007 03:19 1.162.744 mfc90u.dll 07.11.2007 00:5159.904 mfcm90.dll 07.11.2007 00:5159.904 mfcm90u.dll 07.11.2007 00:51 548 Microsoft.VC90.MFC.manifest 26.02.2011 19:1019.968 Pythonwin.exe 04.11.2011 19:07 pywin 26.02.2011 19:11 416.256 scintilla.dll 06.11.2011 23:12 1.446 startframework.pyw 26.02.2011 19:09 778.240 win32ui.pyd 26.02.2011 19:1037.888 win32uiole.pyd 07.11.2011 14:44 _mv 12 Datei(en) 3.743.688 Bytes 4 Verzeichnis(se), 43.545.804.800 Bytes frei Now when I move away the 5 MFC files (4 dlls + manifest) to _mv, then Pythonwin.exe still runs properly! And it does so until I move the folder C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc148 away to C:\WINDOWS\WinSxS\_mv (There are 2 more 9.0 MFC folders in WinSxS, but they have no effect regarding Pythonwin.exe - on or off) Well, but Pythonwin.exe has a builtin manifest (win32api.LoadResource(None, 24, 1)) which draws version="9.0.21022.8" - and not 9.0.30729.* !? how come? : manifestVersion="1.0"> uiAccess="false"> version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"> version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"> Moreover, the files in .. Verzeichnis von C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc 148 10.10.2011 11:04 . 10.10.2011 11:04 .. 18.04.2011 21:51 3.766.600 mfc90.dll 18.04.2011 21:51 3.781.960 mfc90u.dll 18.04.2011 21:5159.904 mfcm90.dll 18.04.2011 21:5159.904 mfcm90u.dll 4 Datei(en) 7.668.368 Bytes 2 Verzeichnis(se), 43.545.792.512 Bytes frei .. are younger than Pythonwin.exe itself !?? Well, now with MFC90 folders of WinSxS moved away, and Pythonwin.exe finally not booting as wanted, I move then back the 5 MFC files from C:\Python27\Lib\site-packages\pythonwin\_mv to C:\Python27\Lib\site-packages\pythonwin . But Pythowin.exe now doesn't start with that files right next to it (where precisely the same version is in Pythonwin.exe manifest and in that Microsoft.VC90.MFC.manifest file), nor does import win32ui in python(w).exe work. (ImportError: DLL load failed: The referenced assembly is not installed on the computer) Pythonwin.exe or win32ui won't load until C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc 148 is in Place. I absolutely don't understand this. How can Pythonwin.exe draw a MFC90 DLL set with future date and future version, and reject the DLL set coming with pywin32 installer right next to with right version ... ? What has to be done to distribute the right binary files for a win32ui app? Where do the "active" rather new files in C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc 148 come from at all? Robert PS: By experience the method with placing MSVCRT 90 files + manifest next to a Python2.6 wxPython app (no MFC/win32ui) worked on fresh computers (which I don't have easily at hand). But here c:\python27\python.exe requires C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43 .. while 'name="Microsoft.VC90.CRT" version="9.0.21022.8"' is in its built-in manifest ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] WinSxS, manifests and binary distribution ?
Mark Hammond wrote: I'm afraid some of the assembly stuff is truly black-magic to me, but I'll answer what I can. On 8/11/2011 1:28 AM, Robert wrote: ... Now when I move away the 5 MFC files (4 dlls + manifest) to _mv, then Pythonwin.exe still runs properly! And it does so until I move the folder C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc148 away to C:\WINDOWS\WinSxS\_mv (There are 2 more 9.0 MFC folders in WinSxS, but they have no effect regarding Pythonwin.exe - on or off) Well, but Pythonwin.exe has a builtin manifest (win32api.LoadResource(None, 24, 1)) which draws version="9.0.21022.8" - and not 9.0.30729.* !? how come? : How come what? The C compiler generates this dependency based on what I have installed, which is VS2008 with no service packs. Moreover, the files in .. Verzeichnis von C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc 148 10.10.2011 11:04 . 10.10.2011 11:04 .. 18.04.2011 21:51 3.766.600 mfc90.dll 18.04.2011 21:51 3.781.960 mfc90u.dll 18.04.2011 21:51 59.904 mfcm90.dll 18.04.2011 21:51 59.904 mfcm90u.dll 4 Datei(en) 7.668.368 Bytes 2 Verzeichnis(se), 43.545.792.512 Bytes frei .. are younger than Pythonwin.exe itself !?? I guess the manifest for that version indicates it supports the older version? yes it seems this file catches with "bindingRedirect" the version request range 9.0.20718.0-9.0.21022.8 to the newest installed MFC90 DLLs: C:\WINDOWS\WinSxS\Policies\x86_policy.9.0.Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_x-ww_4ee8bb30 manifestVersion="1.0"> name="policy.9.0.Microsoft.VC90.MFC" version="9.0.30729.6161" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/> processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/> newVersion="9.0.30729.6161"/> newVersion="9.0.30729.6161"/> Well, now with MFC90 folders of WinSxS moved away, and Pythonwin.exe finally not booting as wanted, I move then back the 5 MFC files from C:\Python27\Lib\site-packages\pythonwin\_mv to C:\Python27\Lib\site-packages\pythonwin . But Pythowin.exe now doesn't start with that files right next to it (where precisely the same version is in Pythonwin.exe manifest and in that Microsoft.VC90.MFC.manifest file), nor does import win32ui in python(w).exe work. (ImportError: DLL load failed: The referenced assembly is not installed on the computer) Pythonwin.exe or win32ui won't load until C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc 148 is in Place. Is it possible that Windows is keeping an index of what is installed, so it *thinks* it will find the assembly in the SxS directory but fails to locate it and doesn't try the directory next to the modules? I absolutely don't understand this. How can Pythonwin.exe draw a MFC90 DLL set with future date and future version, and reject the DLL set coming with pywin32 installer right next to with right version ... ? What has to be done to distribute the right binary files for a win32ui app? Where do the "active" rather new files in C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_028bc 148 come from at all? Probably from something else you installed - pywin32 doesn't install it. Please continue to share whatever you learn :) Mark Robert PS: By experience the method with placing MSVCRT 90 files + manifest next to a Python2.6 wxPython app (no MFC/win32ui) worked on fresh computers (which I don't have easily at hand). finally I inspected with "depends.exe" (which confirmed well the actual happening as far as I see) and tested the simple "shared assembly" distribution method with VCR DLL(s) and MFC DLL(s) too next to the py2exe'd app files on a fresh XP Virtual Machine. Theory can't fully replace try+error ;-) From the list msvcr90.dll Microsoft.VC90.CRT.manifest (not required: msvcp90.dll (c++ libs), msvcm90.dll (managed code)) mfc90.dll Microsoft.VC90.MFC.manifest .exe.manifest .exe.manifest with the same manifest as embedded in Pythonwin.exe (including the MFC request) is needed as max surprise. When missing, "import dde" fails with pywin 216 with that error mention in the thread nearby. Unlike in build 216, pywin 212's dde.pyd here seems to have the same embedded manifest as win32ui.pyd. The problem is not with win32uiole.pyd. So I guess from 214 -> 215 a sort of bug entered into the pywin build files regarding the dde.pyd lacking a embedded manifest. (I added that on SF bug ID 3314345) Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] WinSxS, manifests and binary distribution ?
Michel Claveau wrote: Hi! *sorry for my bad english* I do not know if my problem has same origine that your, but I have a problem with win32ui, only since pywin32/215 when I call a COM server who contain "import win32ui" With versions 215 ot 216, I have this traceback: Traceback (most recent call last): ... File "D:\Dev\python\pywig.py", line 29, in import win32ui ImportError: DLL load failed: Le module spécifié est introuvable. With version 214 or prior, I have no problem. I (re)-install 216: problem. I (re)-install 214: no problem. I had try to re-register the server ; I had try on a dozen of computers, with differents windows (XP, Vista, 7 ; 32 & 64). With Python 2.6 or 2.7. Always the problem. (all my tests with Pywin32 in 32 bits). I can reproduce the problem at will (on my computers). @-salutations I get a different error in COM servers when loading win32ui: "error in DLL initialization", and even before: a error regarding C-Runtime problems. I just see: In 216 there is a different/no reference to the SxS MSVCR90.dll. While in 212 there was a reference to same WinSxS version as in pythonw.exe. This may be a bug, but all that is a little obscure .. If its really just "DLL load failed: Le module spécifié est introuvable." you may add def syspath(self, arg=0): return unicode(sys.path) to your _public_methods_ (and move the import win32ui from global to a function if not already done) and see.. Check also what is actually called in HKEY_CLASSES_ROOT\CLSID\\LocalServer32 Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] manifest "Microsoft.Windows.Common-Controls" version="6.0.0.0" => strange problem with pywin32 build 216 ?
In C:\Python23 and C:\Python26 installations there are python(s).exe.manifest files which contain '"Microsoft.Windows.Common-Controls" version="6.0.0.0"' (see attached/below) With pywin32 build 216 (was not in 212; and 214 I guess) win32ui apps, which are started by these python(w).exe's , a strange auto-magical button pressing is going on, immediately after application start. almost any button is pressed when the mouse moves.. By chance its possible to stop the show in the Task Manager. It seems (seen by a debug output), that notification messages (BN_.. (Which could be routed via HookNotify?)) or so do trigger the normal HookCommand'ed handler. When that Common-Controls section (or the whole .manifest) is removed, the apps work normal in build 216. What could be the reason? What does this Common-Control section actually do? Robert -- manifestVersion="1.0"> Python Interpreter manifestVersion='1.0'> uiAccess='false' /> Python Interpreter ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] SIGSEGV crash at the end of apps using win32uiole / OCX
This is about a ugly old bug which I dislike for long, which I can only suppress by a os._exit() near Python end. Now I found some more info. Perhaps somebody sees what it is about? When a GUI app has ever used a win32uiole OCX like shown in the attached minimal example (pythonwin\pywin\Demos\ocx\webbrowser.py, just changed to use a standalone frame window), then at the very end of the app after all windows have been destroyed and Pythons sort of main() with destruction of all Python objects is reached, there is a SIGSEGV like shown below in python26!PyInterpreterState_Clear (). Reproduced with various Python 2 versions. Notes: * Obviously extra threads are created by the browser OCX if at least one .Navigate() occurred. * if .Navigate() is commented out, and just the Window/OCX creations/destructions are done the problem is not. (But then gdb doesn't show creation of extra threads. Thus the problem seems to have to do with extra threads.) * "app.Run()" is commented out for a mere standalone run, to reproduce the bug easily. Thus the windows are drawn down right after creation. If not, then at exit, this (simple) app somehow doesn't terminate but seems to wait eternally because of extra IE4 threads (?). When run with gdb as shown, the hang/eternal wait yet is not and the SIGSEGV occurs after .Run() too (!?) * the problem is not, when the example is run in Pythonwin.exe at the end of Pythonwin.exe. The problem is not when such script is run with py2exe v0.5.2 stub. (maybe that does rather quickly something like os._exit() at the end). But the problem occurs with current py2exe 0.6.9 stub, and with all normal python(w).exe's - direct start or via interactive sessions. When Pythonwin is run via python(w).exe and "import pywin.framework.startup app.Run()", and when then the webbcrash.py is executed, then after exit of Pythonwin the crash is there too. Thus Pythonwin.exe unlike python(w).exe seems to do just a sloppy cleanup (like py2exe0.5.2) and thus avoid the problem. * when os._exit() is done at the end of the script, the problem is not existing: the ugly "solution" ;-) sys.exit() doesn't "solve" - probably because it doesn't prevent against destruction of all Python objects, threads ... * pywin32 build 216 (but same with 214) * BTW: if the original pythonwin\pywin\Demos\ocx\webbrowser.py (using a MDIClient) is run standalone through python(w).exe, there is also a ugly SIGSEGV or even worse C-level crash - now at start. It should only raise a Python exception due to the non-working MDI setup I guess. Robert === SIGSEV of webbcrash.py watched with gdb : SIGSEGV: code "mov 0x4(%ebx),%eax" at 0x1e02e449 points to memory 0x0004. cannot read. C:\scratch>python26 webbcrash.py Run() ... Run() terminated. ==> SIGSEGV crash [uncomment "##app.Run()"] C:\scratch>gdb python26 webbcrash.py GNU gdb (GDB) 7.2 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "mingw32". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from C:\bin/python26.exe...(no debugging symbols found)...done. "C:\scratch/webbcrash.py" is not a core dump: File format not recognized (gdb) run Starting program: C:\bin/python26.exe (NOTE: ITS THE SAME WITH C:\Python26\python.exe) [New Thread 6740.0x10bc] Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on2 win32 Type "help", "copyright", "credits" or "license" for more information. >>> execfile('webbcrash.py') Web Browser - http://www.google.com/ [New Thread 6740.0x19d0] [New Thread 6740.0xdec] [New Thread 6740.0x1d90] [New Thread 6740.0x1f00] [New Thread 6740.0x19cc] [New Thread 6740.0x26c] [New Thread 6740.0x118c] [New Thread 6740.0x153c] [New Thread 6740.0x1da0] >>> exit() Program received signal SIGSEGV, Segmentation fault. 0x1e02e449 in python26!PyInterpreterState_Clear () from C:\WINDOWS\system32\python26.dll (gdb) bt #0 0x1e02e449 in python26!PyInterpreterState_Clear () from C:\WINDOWS\system32\python26.dll #1 0x in ?? () (gdb) disass ... 0x1e02e408 <+246>: call 0x1e02e464 0x1e02e40d <+251>: mov%eax,0x50(%esi) 0x1e02e410 <+254>: mov%edi,0x40(%esi) 0x1e02e413 <+257>: mov%edi,0x28(%esi) 0x1e02e416 <+260>: mov%edi,0x2c(%esi) 0x1e02e419 <+263>: mov%edi,0x30(%esi) 0x1e02e41c <+266>: mov%edi,0x34(%esi) 0x1e02e41f
Re: [python-win32] Several, totally isolated Python interpreters in the same process
Thomas Heller wrote: I made an experiment that I wanted to share because it is imo kind of cool: I managed to embed a second Python interpreter in a Python process, with help of WinSxS (WinSxS is a Microsoft technology that allows to isolate plugins from other plugins, or from the calling process). The second interpreter is totally isolated from the calling process. The idea is to use this technology to decouple COM extensions implemented in Python from the caller and from other COM extensions. But there may be other uses as well... The code is here: http://code.google.com/p/ctypes-stuff/source/browse/trunk/winsxs is it necessary to have extra python files for each instance? or could one existing python installation run in multiple instances too this way ? Robert Information I found useful about WinSxS and assemblies: http://msdn.microsoft.com/en-us/library/dd408052%28v=VS.85%29.aspx http://omnicognate.wordpress.com/2009/10/05/winsxs/ Thomas ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] How to get URL of open browser window?
What is the best way to get the URL of current open webbrowser Window (topmost) into a utility script? At least for IE & Mozilla's Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] SetSystemTime: A required privilege is not held by the client
SetSystemTime on Vista admin account throws: (1314, 'SetSystemTime', 'A required privilege is not held by the client.') Not known from previous Windows versions. With what switch or whatever can this be enabled? Robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Python Service error 1053: the service did notrespond to the start or control request in a timely fashion
From: "Richard Zinn" Hi, I've implemented the MyService.py example from the py2exe samples directory using Python2.6, on my Windows XP SP2, and I get the error 1052...did not respond in a timely fashion immediately when I run the MyService.py, or the MyService.exe, or if I install it as a service using an NSIS installer script I wrote, and start it using the windows service manager. Any ideas? Here is the code reduced to just the essentials: import win32serviceutil import win32service import win32event import win32evtlogutil class MyService(win32serviceutil.ServiceFramework): _svc_name_ = "MyService" _svc_display_name_ = "My Service" _svc_deps_ = ["EventLog"] def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): import servicemanager log("running") win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) log("stopped") if __name__ == '__main__': win32serviceutil.HandleCommandLine(MyService) I've seen other posters with similar problems, but with theirs it doesn't work in the .exe, but in my case it doesn't work when I run the .py either. The traceback in python says: python MyService.py Collecting Python Trace Output... Traceback (most recent call last): File "C:\Python26\Lib\site-packages\win32\lib\win32serviceutil.py", line 399, in StartService win32service.StartService(hs, args) pywintypes.error: (1053, 'StartService', 'The service did not respond to the sta rt or control request in a timely fashion.') Thanks in advance, Richard If SvcDoRun is run in it's own thread, then I suspect the import residing inside that function. If I remember correctly, Python's import mechanism causes the thread where the import takes place to deadlock, so you should always perform an import inside your main thread. Try importing servicemanager from the top of your script, instead of inside of SvcDoRun. Then your example should start throwing exceptions because it can't find 'log.' :-) ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Python Service Won't Start, But Does Debug
I'm new to using the win32 module and I've written a little service in python for myself. It runs fine and without errors when I use debug: >python myService.py debug Debugging service myService - press Ctrl+C to stop. This works and prints to a log file I set up just fine, so I know it's working properly However when I try using the start command on the same service It says it's started, but hasn't: >python myService.py start Starting service myService Then after any amount of time: >python myService.py stop Stopping service myService Error stopping service: The service has not been started. (1062) If I use a wait command: >python myService.py --wait=30 start Starting service myService Error starting service: The service did not respond to the start or control request in a timely fashion. I'm using python 2.5 and the win32module. My main class is a subclass of win32serviceutil.ServiceFramework with all the appropriate function overridden (__init__, SvcStop, SvcDoRun) the init function calls the init function of the ServiceFramework directly (not using super). When debugging it will continually run it's main loop and does everything in it I would expect, but seems to not to want to run when using start. Obviously no exceptions are thrown when I run it in debug mode. Any suggestions, or should I be posting more info? ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] making icons on task bar require double-click
This can be accomplished with the wxPython lib. On Oct 22, 2009, at 7:21 PM, Tim Roberts wrote: Randy Syring wrote: Is it possible, with a python program, to run through the task bar icons and change them so that their current single-click event would get transferred to a double-click event? I click them by mistake sometimes and its very annoying to wait for the program to open just so I can close it. I haven't been able to find a way to accomplish this natively so I figured a python script set to run when my user logs in and the windows extensions might do the trick. In short, no. This requires an injectable window hook, and there is at present no way to do that kind of window hook in Python. How do you happen to click on these accidentally? Perhaps there are other ways to solve this. For example, you can configure the taskbar so that it hides itself unless you hover the mouse at the bottom of the screen. Or, you can drag the taskbar to any other edge of the screen. If you find yourself hovering around the bottom edge most of the time, perhaps moving the taskbar to the top would solve that. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] making icons on task bar require double-click
I apologize. I think I misread what you are trying to accomplish. It sounds like you want to do this for icons that you did not create. I do not think this is possible with wxPython. On Oct 23, 2009, at 11:05 AM, Robert Liebeskind wrote: This can be accomplished with the wxPython lib. On Oct 22, 2009, at 7:21 PM, Tim Roberts wrote: Randy Syring wrote: Is it possible, with a python program, to run through the task bar icons and change them so that their current single-click event would get transferred to a double-click event? I click them by mistake sometimes and its very annoying to wait for the program to open just so I can close it. I haven't been able to find a way to accomplish this natively so I figured a python script set to run when my user logs in and the windows extensions might do the trick. In short, no. This requires an injectable window hook, and there is at present no way to do that kind of window hook in Python. How do you happen to click on these accidentally? Perhaps there are other ways to solve this. For example, you can configure the taskbar so that it hides itself unless you hover the mouse at the bottom of the screen. Or, you can drag the taskbar to any other edge of the screen. If you find yourself hovering around the bottom edge most of the time, perhaps moving the taskbar to the top would solve that. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] making icons on task bar require double-click
I apologize. I think I misread what you are trying to accomplish. It sounds like you want to do this for icons that you did not create. I do not think this is possible with wxPython. On Oct 23, 2009, at 11:05 AM, Robert Liebeskind wrote: This can be accomplished with the wxPython lib. On Oct 22, 2009, at 7:21 PM, Tim Roberts wrote: Randy Syring wrote: Is it possible, with a python program, to run through the task bar icons and change them so that their current single-click event would get transferred to a double-click event? I click them by mistake sometimes and its very annoying to wait for the program to open just so I can close it. I haven't been able to find a way to accomplish this natively so I figured a python script set to run when my user logs in and the windows extensions might do the trick. In short, no. This requires an injectable window hook, and there is at present no way to do that kind of window hook in Python. How do you happen to click on these accidentally? Perhaps there are other ways to solve this. For example, you can configure the taskbar so that it hides itself unless you hover the mouse at the bottom of the screen. Or, you can drag the taskbar to any other edge of the screen. If you find yourself hovering around the bottom edge most of the time, perhaps moving the taskbar to the top would solve that. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] making icons on task bar require double-click
I apologize. I think I misread what you are trying to accomplish. It sounds like you want to do this for icons that you did not create. I do not think this is possible with wxPython. On Oct 22, 2009, at 7:21 PM, Tim Roberts wrote: Randy Syring wrote: Is it possible, with a python program, to run through the task bar icons and change them so that their current single-click event would get transferred to a double-click event? I click them by mistake sometimes and its very annoying to wait for the program to open just so I can close it. I haven't been able to find a way to accomplish this natively so I figured a python script set to run when my user logs in and the windows extensions might do the trick. In short, no. This requires an injectable window hook, and there is at present no way to do that kind of window hook in Python. How do you happen to click on these accidentally? Perhaps there are other ways to solve this. For example, you can configure the taskbar so that it hides itself unless you hover the mouse at the bottom of the screen. Or, you can drag the taskbar to any other edge of the screen. If you find yourself hovering around the bottom edge most of the time, perhaps moving the taskbar to the top would solve that. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Python script jumps back to 'main' in long running win32 event
Hi, I'm hoping that someone can help with this... I've seen some old posts which I think may refer to this same issue but I'm having difficulty understanding how to come up with a solution, and particularly where any "PumpWaitingMessages" should be located and/or/how/whether pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) should be used. The code processes data for 25/30 messages received back from the com object but then seems to jump back to the 'if __name__ == '__main__' and passes that same parameter (originally passed from the command line) and runs all over again... The process is intended to: 1. pass a parameter from the command line 2. open a [pickle] file to store the data 3. call a COM object with Dispatch events (to an EventHandler) 4. for each block of data received back into the EventHandler, drop it into the pickle 5. close the pickle file I'd be immensely grateful for any assistance you can give. Rob Essentially the skeleton code I have (and I hope it's intelligible) is as follows: if __name__ == '__main__': arg = sys.argv[1:] proc(arg[0]) def proc(arg): fh = file("thispickle.pkl", 'wb') x = Async(arg) # see below fh.close() [in a seperate module I have the following construct for the Dispatch] class EventHandler: def onData(self, event): # do stuff with data in 'event' cPickle.dump(data, self.fh) # flag this as 'done' class Async: def __init__(self, params): #pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) # should this go here?? s = win32com.client.DispatchWithEvents('com_obj' , EventHandler) self.finished = False while not self.finished: PumpWaitingMessages() if messages_all_flagged: self.finished = True ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Can't access methods of COM object.
I have been successful in the past using COM from Python to control ActiveX elements such as LabView programs and a few third-party device servers. I recently tried to integrate a new component which came with a LabView example and some Visual Basic sample code. The LabView example works for me and I can examine the methods and properties of the server but I can't seem to do anything with the server from Python. I can successfully get an instance with: >>>ps = Dispatch("PPServer.PPServerClass") >>>ps 0x20239664> >>>cha = ps.ChannelA <--- Fails and none of the expected methods or properties are exposed except those seen in the attached genpy file. The VB example shows: Set pps = New PServer cha = pps.ChannelA I've tried various combinations, in Python, of ps.ChannelA, ps.Start() etc and none of the documented methods or properties seem to work. Any thoughts on how to proceed? Thanks Rob # -*- coding: mbcs -*- # Created by makepy.py version 0.5.00 # By python version 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] # From type library 'sniffpol.dll' # On Wed Nov 03 09:43:53 2010 """PPServer 1.0 Type Library""" makepy_version = '0.5.00' python_version = 0x20700f0 import win32com.client.CLSIDToClass, pythoncom, pywintypes import win32com.client.util from pywintypes import IID from win32com.client import Dispatch # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing, .Empty and .ArgNotFound defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty CLSID = IID('{23D1AE21-8023-11D3-8D47-00C04F949D33}') MajorVersion = 1 MinorVersion = 0 LibraryFlags = 8 LCID = 0x0 from win32com.client import DispatchBaseClass class IPPServerClass(DispatchBaseClass): """IPPServerClass Interface""" CLSID = IID('{23D1AE2F-8023-11D3-8D47-00C04F949D33}') coclass_clsid = IID('{23D1AE30-8023-11D3-8D47-00C04F949D33}') def AllowAutomaticSniffing(self): """method AllowAutomaticSniffing""" return self._ApplyTypes_(1, 1, (12, 0), (), u'AllowAutomaticSniffing', None,) _prop_map_get_ = { } _prop_map_put_ = { } from win32com.client import CoClassBaseClass # This CoClass is known by the name 'PPServer.PPServerClass.1' class PPServerClass(CoClassBaseClass): # A CoClass # PPServerClass Class CLSID = IID('{23D1AE30-8023-11D3-8D47-00C04F949D33}') coclass_sources = [ ] coclass_interfaces = [ IPPServerClass, ] default_interface = IPPServerClass IPPServerClass_vtables_dispatch_ = 1 IPPServerClass_vtables_ = [ (( u'AllowAutomaticSniffing' , u'pvarShow' , ), 1, (1, (), [ (16396, 10, None, None) , ], 1 , 1 , 4 , 0 , 28 , (3, 0, None, None) , 0 , )), ] RecordMap = { } CLSIDToClassMap = { '{23D1AE2F-8023-11D3-8D47-00C04F949D33}' : IPPServerClass, '{23D1AE30-8023-11D3-8D47-00C04F949D33}' : PPServerClass, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} VTablesToClassMap = { '{23D1AE2F-8023-11D3-8D47-00C04F949D33}' : 'IPPServerClass', } NamesToIIDMap = { 'IPPServerClass' : '{23D1AE2F-8023-11D3-8D47-00C04F949D33}', } ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] python-win32 Digest - Can't access COM methods
Hi Tim, (I wasn't sure how to target your response in the digest. Hope this worked out OK.) Message: 2 Date: Fri, 5 Nov 2010 13:22:04 -0700 From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] Can't access methods of COM object. Message-ID:<4cd4676c.8000...@probo.com> Content-Type: text/plain; charset="ISO-8859-1" Robert Norman wrote: I have been successful in the past using COM from Python to control ActiveX elements such as LabView programs and a few third-party device servers. I recently tried to integrate a new component which came with a LabView example and some Visual Basic sample code. The LabView example works for me and I can examine the methods and properties of the server but I can't seem to do anything with the server from Python. I can successfully get an instance with: >>>ps = Dispatch("PPServer.PPServerClass") ... The VB example shows: Set pps = New PServer That's not the same thing. Is that actually "New PPServerClass"? When I examine the return object, it is a PPServer not the PPServerClass but can't find any way to go the next step. In previous experience with LabView servers, the Dispatch statement gives me usable COM objects. Rob ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ImportError: DLL load failed
Mark Hammond gmail.com> writes: > > On 13/07/2012 10:45 AM, Jane Chen wrote: > > Hi all, > > > > I would like to add python win32 to Portable Python distribution with > > PyGTK for Windows > > http://fnch.users.sourceforge.net/portablepygtkwindows.html > > I installed the pywin32 in the python\Lib\site-packages folder. PC #1 > > can find win32api.pyd. After that, I copied the whole portable python > > distribution folder to PC#2. I got the following message: > > import win32file, win32api > > ImportError: DLL load failed: The specified module could not be found. > > > > Can anyone please help me with this issue? > > I'm guessing that pywintypes27.dll and pythoncom27.dll aren't anywhere > on the PATH on PC#2 - try copying them next to python.exe. > > HTH, > > Mark > This was the answer for me. I had tried moving the .pyd files next to the .exe, but you had the answer Mark. When I saw your response I had already searched through enough forum to recognize your name and know your were the THE guy. Thanks for your time skill and willingness to share your code and knowledge. ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
[python-win32] Dr. Watson woes with ADO, mysql
Hello all, I've spent the last year writing an ORM in Python which I'm reasonably pleased with. But I have a recent problem: I can't seem to migrate tables from Microsoft Access (using ADO) to MySQL (using MySQLdb) without a crash. But, don't let the context fool you: when it crashes, I don't think I'm doing *anything* with the ADO connection, and I actually get the same crash when using Postgres instead of MySQL. I'm not a Windows guru by any means, but I have noticed a pattern: throughout my (many, naive) code changes to try to avoid the crash, the same functions keep popping up in drwtsn32.log: function: PyComplex_AsCComplex function: NtWaitForSingleObject (multiple times) function: NtWaitForMultipleObjects function: ZwReplyWaitReceivePortEx function: NtDelayExecution function: ScrollDC ...where PyComplex_AsCComplex is the first one listed, and (if I'm reading MSDN correctly) is therefore the function "where the fault occurred". So the question is, what's the next step in tracking down the bug? PyComplex_AsCComplex is a pretty simple function. Or am I way off-base and should be looking elsewhere? Robert Brewer MIS Amor Ministries [EMAIL PROTECTED] Application exception occurred: App: (pid=1436) When: 1/10/2005 @ 10:31:47.869 Exception number: c005 (access violation) *> System Information <* Computer Name: REDROVER User Name: rbre Number of Processors: 1 Processor Type: x86 Family 15 Model 2 Stepping 7 Windows 2000 Version: 5.0 Current Build: 2195 Service Pack: 4 Current Type: Uniprocessor Free Registered Organization: Registered Owner: Valued Sony Customer *> Task List <* 0 Idle.exe 8 System.exe 156 SMSS.exe 180 CSRSS.exe 176 WINLOGON.exe 228 SERVICES.exe 240 LSASS.exe 420 svchost.exe 448 spoolsv.exe 524 svchost.exe 544 sqlservr.exe 620 sqlservr.exe 636 mysqld-nt.exe 672 pg_ctl.exe 792 postmaster.exe 800 WinMgmt.exe 808 inetinfo.exe 908 postgres.exe 924 postgres.exe 944 postgres.exe 964 postgres.exe 1264 explorer.exe 1324 PcfMgr.exe 1168 Apoint.exe 1144 prpcui.exe 1132 WlanUtil.exe 1120 atiptaxx.exe 1112 qttask.exe 604 PhoneManager.ex.exe 1444 ApntEx.exe 1452 sqlmangr.exe 548 CMD.exe 1340 mysql.exe 1488 openvpnserv.exe 492 openvpn.exe 600 Pythonwin.exe 784 CMD.exe 1332 CMD.exe 1436 python.exe 1500 DRWTSN32.exe 0 _Total.exe (1D00 - 1D005000) (77F8 - 77FFD000) (1E00 - 1E0F) (7C57 - 7C623000) (77E1 - 77E75000) (77F4 - 77F7B000) (7C2D - 7C332000) (77D3 - 77DA1000) (782F - 78535000) (6318 - 631E9000) (7800 - 78045000) (7171 - 71794000) (75E6 - 75E7A000) (1E1E - 1E1EE000) (1D18 - 1D18B000) (1E1D - 1E1DC000) (7505 - 75058000) (7503 - 75044000) (7502 - 75028000) (1000 - 1007C000) (1D11 - 1D115000) (00E6 - 00E73000) (77A5 - 77B3F000) (779B - 77A4B000) (0129 - 012DE000) (012E - 012F) (7782 - 77827000) (759B - 759B6000) (7C34 - 7C34F000) (013F - 01426000) (782C - 782CC000) (7798 - 779A4000) (7734 - 77353000) (7752 - 77525000) (7732 - 77337000) (7515 - 7515F000) (7517 - 751BF000) (77BF - 77C01000) (7795 - 7797A000) (751C - 751C6000) (773B - 773DF000) (7738 - 773A3000) (7783 - 7783E000) (7788 - 7790E000) (7C0F - 7C151000) (774E - 77513000) (774C - 774D1000) (7753 - 77552000) (7736 - 77379000) (777E - 777E8000) (777F - 777F5000) (74FD - 74FEE000) (7501 - 75017000) (775A - 7763) (1F44 - 1F4BD000) (1F67 - 1F693000) (76B3 - 76B6E000) (1F89 - 1F8FC000) (1F90 - 1F911000) (1B57 - 1B5C5000) (1B00 - 1B17) (1B5D - 1B665000) (1B2C - 1B2CD000) (1B2D - 1B2F6000) (7874 - 788AF000) (6DE8 - 6DEE4000) (6DF8 - 6E037000) (6A7A - 6A7B) (7393 - 7394) (689D - 689DD000) (1B81 - 1B84A000) (0F9A - 0F9AB000) (0F9C - 0FA22000) (1F53 - 1F53D000) State Dump for Thread Id 0x5cc eax=0001 ebx=00cee0a0 ecx=0001 edx=1e0b4480 esi=1e0b2317 edi=0005 eip=1e0328ee esp=0012e910 ebp=0001 iopl=0 nv up ei pl nz na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs= efl=0202 function: PyComplex_AsCComplex *> Stack Back Trace <* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0001 !PyComplex_AsCComplex *> Raw Stack Dump <* 0012e910 a0 e0 ce 00 01 00 00 00 - a0 34 7f 00 06 00 00 00 .4.. 0012e920 e2 cf 02 1e a0 e0 ce 00 - 17 23 0b 1e 01 00 00 00 .#.. 0012e930 f0 96 b3 00 46 ae 02 1e - f0 96 b3 00 17 23 0b 1e F#.. 0012e940 01 00 00 00 a0 34 7f 00 - f0 96 b3 00 ff
RE: [python-win32] Dr. Watson woes with ADO, mysql
I wrote: > > I've spent the last year writing an ORM in Python which I'm > reasonably > > pleased with. But I have a recent problem: I can't seem to migrate > > tables from Microsoft Access (using ADO) to MySQL (using MySQLdb) > > without a crash. But, don't let the context fool you: when it > > crashes, I > > don't think I'm doing *anything* with the ADO connection, and > > I actually > > get the same crash when using Postgres instead of MySQL. > > > > I'm not a Windows guru by any means, but I have noticed a pattern: > > throughout my (many, naive) code changes to try to avoid the > > crash, the > > same functions keep popping up in drwtsn32.log: > > > > function: PyComplex_AsCComplex > > function: NtWaitForSingleObject (multiple times) > > function: NtWaitForMultipleObjects > > function: ZwReplyWaitReceivePortEx > > function: NtDelayExecution > > function: ScrollDC and Mark Hammond replied: > All except the first and last are quite usual. I'm not sure > where ScrollDC has come from - are you using this from a GUI? No, from a DOS prompt (cmd.exe). However, I get similar problems launching from Pythonwin interactively. > > ...where PyComplex_AsCComplex is the first one listed, and (if I'm > > reading MSDN correctly) is therefore the function "where the fault > > occurred". > > > > So the question is, what's the next step in tracking down the bug? > > PyComplex_AsCComplex is a pretty simple function. Or am I > way off-base > > and should be looking elsewhere? > > If a GUI is involved, you should try and make sure you are > living within its thread constraints. Its possible to cause > a crash by mixing threading up in a GUI. > > PyComplex_AsCComplex does indeed look simple, but my guess is > that given the trouble you are having reproducing, there is a > subtle reference-count bug somewhere, and quite possibly > relating to complex numbers. Given the nature of such bugs, > the place where the crash occurs is generally *not* the place > with the bug. Okay. This is probably especially true since my app doesn't handle any complex numbers (at least not in my code). I also can't find complex mentioned anywhere in the ADO COM lib (in gen_py) or in the _mysql.pyd C code (which I call directly instead of using the DBAPI wrapper). http://cvs.sourceforge.net/viewcvs.py/mysql-python/mysql/_mysqlmodule.c? rev=1.42&view=auto > Unfortunately, we are piling speculation on speculation. > Personally I would get a debug build running, so a decent > stack-trace is available, but I understand that may not be an option. ...for which I'd need vc++, right? IIRC, I'd need at least version 7? Would "Visual Studio .NET Professional Edition 2003" be okay? I can get that cheap from TechSoup. ;) I'm willing to do the research if I can just get pointed in the right direction. Thanks for the help so far! Robert Brewer MIS Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Greetings and win32 com events question
Hi, I'm new to the mailing, so greetings all! I'm working on an application try to respond to events in Microsoft Access using Python and win32com. However, I'm having trouble in setting up the event handlers. I can think of 2 approaches both of which yield win32com errors. First is the approach used the MSOfficeEvents.py test program. The problem is that the events to be picked up are not on the Application object but on a Form object created from it. class AccessEvents def OnActivate(self): print "Hello from Access" return 1 self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. fm = DispatchWithEvents (self. fm, AcEvents) blows out with self. fm = DispatchWithEvents (self. fm, AcEvents) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 258, in DispatchWithEvents clsid = disp_class.CLSID AttributeError: 'NoneType' object has no attribute 'CLSID'. I also tried a variety of string arguments, but all of those also yielded an invalid class id error. The other approach is more Visual Basic like: self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. ev = AcEvents () self. fm. OnActivate = self. ev. OnActivate this couldn't set the OnActivate attribute with the following error. File "D:\pyhack\1\Bob.py", line 132, in DoAccess self. fm. OnActivate = self. ev. OnActivate File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 503, in __setattr__ d.__setattr__(attr, value) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) TypeError: Objects of type 'instance method' can not be converted to a COM VARIA NT Anyone know how to do this, either strategy is fine. Thanks Robert Kaplan ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Re: Greetings and win32 com events question (Typo corrected)
Hi, Apologies, I screwed up with a typo. AcEvents was another class identical to AccessEvents. The problem is the same. class AcEvents def OnActivate(self): print "Hello from Access" return 1 self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. fm = DispatchWithEvents (self. fm, AcEvents) blows out with self. fm = DispatchWithEvents (self. fm, AcEvents) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 258, in DispatchWithEvents clsid = disp_class.CLSID AttributeError: 'NoneType' object has no attribute 'CLSID'. Second code snippet has the same screwup: self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. ev = AcEvents () self. fm. OnActivate = self. ev. OnActivate this couldn't set the OnActivate attribute with the following error. File "D:\pyhack\1\Bob.py", line 132, in DoAccess self. fm. OnActivate = self. ev. OnActivate File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 503, in __setattr__ d.__setattr__(attr, value) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) TypeError: Objects of type 'instance method' can not be converted to a COM VARIANT Tim Golden wrote: [Robert Kaplan] | I'm new to the mailing, so greetings all! Welcome. As a word of warning, this is a relatively low-activity list and I don't know what the overlap is between this and the main python list. If you get no response (or no solution) here, you might want to try the Python list. | I'm working on an application try to respond to events in Microsoft | Access using Python and win32com. | class AccessEvents | def OnActivate(self): | print "Hello from Access" | return 1 | | | self. ac = Dispatch ("Access.Application") | self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") | self. fm = self. ac. CreateForm () | self. ac. Visible = true | self. fm = DispatchWithEvents (self. fm, AcEvents) | | blows out with | | self. fm = DispatchWithEvents (self. fm, AcEvents) | File | "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line | 258, in | DispatchWithEvents | clsid = disp_class.CLSID | AttributeError: 'NoneType' object has no attribute 'CLSID'. Well, it's not clear from your code, but the third parameter to DispatchWithEvents should be a *class* and not an *instance*. Since AcEvents isn't defined anywhere within your code snippet, it's hard to see which it is, but just in case... That said, I can't for the life of me see why that would raise the error you're showing, but first things first. TJG ___ ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Strange page header text in PythonWin
Title: Message Hello List, Can anyone please point in the correct direction to resolve this minor printing annoyance. When printing a copy of my code, why is the header using strange characters and not readable text as expected ? Thanks in advance! Robert ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Strange page header text in PythonWin
Title: Message I am somewhat of a newbie to Python, but thanks for the heads-up on where to look. Question, since I have not customized anything that I am aware of, my Python environment should be as installed from scratch, so why would I get then strange text in page header ? I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin 2.3.3 win32all build 163 Thanks, Robert -Original Message-From: Mark Hammond [mailto:[EMAIL PROTECTED] Sent: Thursday, June 02, 2005 3:47 PMTo: 'Robert Adams'; 'python-win32'Subject: RE: [python-win32] Strange page header text in PythonWin I'm afraid you would need to look in pythonwin\pywin\scintilla\view.py and try to determine what is going wrong. Cheers, Mark -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Robert AdamsSent: Friday, 3 June 2005 4:24 AMTo: python-win32Subject: [python-win32] Strange page header text in PythonWin Hello List, Can anyone please point in the correct direction to resolve this minor printing annoyance. When printing a copy of my code, why is the header using strange characters and not readable text as expected ? Thanks in advance! Robert ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] IIS CGI installation
Dan Fulbright wrote: > I have found a lot of links to > http://www.e-coli.net/pyiis_server.html, > however, this page starts out with: > > "This is really very easy. It is also not a good idea for > both security and performance reasons." > > What are the security and performance issues, and how can they be > overcome? I am wanting to use Python for CGI on a shared Windows 2000 > Server with IIS, so security and performance are of utmost importance. It's probably considered insecure because you are passing params (%s) to python on the command line. Those "clever hackers" could find a way to pass Nasty Things, like "del C:" Performance will be intolerable, since each page request has to start and stop the Python interpreter, which is not a quick process. There are other ways of using Python with IIS, such as ISAPI + WSGI: http://isapi-wsgi.python-hosting.com/ or ASP: http://www.4guysfromrolla.com/webtech/082201-1.shtml or (my preferred method) ASP + WSGI: http://www.amorhq.net/blogs/index.php/fumanchu/2005/05/26/wsgi_gateway_f or_asp_microsoft_iis If you used the latter, you could use CherryPy and be on the cutting edge of Python web development. :) Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] import and asp-python and iis - strange behaviour
Simon Hook wrote: > I am trying to use import in an asp python page. If I have: > > <%@ LANGUAGE = Python%> > <% > import myfile > %> > > Then myfile can only be found if its in the root of the > python install directory, e.g. c:\python23 > and only if the file is called myfile.py and it contains > python NOT asp code. If I have some python code and it is > loaded by a webpage, if I make any changes to the code > in myfile.py the changes do not come into effect unless > I reboot my machine. I tried start/stop/start iis but that > has no effect, I tried open/close/open and I tried the python > reload() command. None of these had any effect. > > The only way I could get an asp-python file included was to > use the asp include: > > > > How can I get asp to pull python code from another directory > and how can I make a change and not have to reboot for the > change to be invoked? Can I use import with an asp page? That's odd. When you say "stop/start iis" are you only restarting the www service? I find that the following works: open the Internet Services Manager, right click on the computer and choose "Restart IIS..." from the menu, then "Restart Internet Service on machinename". AFAICT, any code inside an .asp file will be reloaded whenever it changes. Any code within an imported .py file requires the restart I described above. FWIW I've had some issues in the past with "import myfile", and I find "from mypackage import mfile" to be more reliable. Sorry; I don't have any hard data on that at the moment--lost in the mists of history. But everything I import in .asp files sits in my site-packages folder anyway. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Editor Replace function limitation
Title: Message Hi, Do I have a setup issue or is the PythonWin editor Replace function limited to 30 characters ? Thanks in advance, Robert ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Editor Replace function limitation
Thanks for both your input on this. I can recreate the problem as follows: Create a script file with the following, 123456789012345678901234567890123456789. Cut/paste into the "Find What" window, I then only get 12345678901234567890123456, that is 26 characters not 30, so I obviously can not count either. Enter var_x, including a space after x into the "Replace with" window, then hit replace. And I end up with var_x 7890123456789 Also, if I keep typing my window does not scroll as you describe. I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin 2.3.3 win32all build 163, and FYI, I am forced to run this version in support of CAD system. Regards, Robert -Original Message- From: John Machin [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 08, 2005 2:45 PM To: Graeme Glass; Robert Adams Cc: python-win32 Subject: Re: [python-win32] Editor Replace function limitation Graeme Glass wrote: >On python 2.3.4 pythonwin build 203, i don't seem to have a problem. >can replace much more than 30 chars. >Not sure what your problem could be, but just thought that i would let >you know it's must your setup not pythonwin. > > Graeme, what "setup" do you refer to? PythonWin appears to have no configuration opportunity for changing the max size of a text replacement -- and indeed I can't imagine that any text editor would ever have had such an option, especially after malloc() was invented ... >(you proberbly already tried this,) but try installing the a diffrent build. > >On 6/8/05, Robert Adams <[EMAIL PROTECTED]> wrote: > > >> >>Do I have a setup issue or is the PythonWin editor Replace function limited >>to 30 characters ? >> >> Robert, It worked for me on 2.4.1 / build 204. I typed in "abc" then replaced "b" by "abyzAB...JK". The size of the box for typing in the replacement string is only 30 characters, but it does scroll if you keep on typing -- have you tried this? What makes you think it is limited to 30 characters? Regards, John ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Pythonwin COM problem
I have a module where I use COM to communicate with some HW drivers. In my module I use CoInitializeEx to init COM in multithreaded mode. However, when I use PythonWin to debug/test my module, I get an error due to the fact that PythonWin has (implicitly) initialized COM in apartment threaded mode. Subsequently, my module crashes Python. How, when and where PythonWin initializes COM (apartment threaded) I don't know, but the fact is it does do that since even if I remove my modules CoInitializeEx, COM works up to the point where a different thread uses a marshalled COM interface (CRASH!) If I use my module via a .py script and run that directly, everything works fine! So, how do I make sure PythonWin (implictly) inits COM in multithreaded mode? TIA /Rob Ps. I've set the sys.coinit_flags (in localserver.py) to zero (value of COINIT_MULTITHREADED), recompiled it, but that didn't change anything... ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Unicode style in win32/PythonWin
Neil Hodgson wrote: > Robert: > > > After "is_platform_unicode = ", scintilla displays some unicode > > as you showed. but the win32-functions (e.g. MessageBox) still do not > > pass through wide unicode. > > Win32 issues are better discussed on the python-win32 mailing list > which is read by more of the people interested in working on this library. > http://mail.python.org/mailman/listinfo/python-win32 > Patches that improve MessageBox in particular or larger sets of > functions in a general way are likely to be welcomed. ok. I have no patches so far as of now - maybe later. Played with Heller's ctypes for my urgent needs. That works correct with unicode like this: >>> import ctypes >>> ctypes.windll.user32.MessageBoxW(0,u'\u041f\u043e\u0448\u0443\u043a.txt',0,0) 1 My recommendation for the general style of unicode integration in win32 in future: * output-functions should dispatch auto on unicode paramams in order to use the apropriate xxxW-functions * input-functions (which are used much more infrequent in apps!) should accept an additional unicode=1 parameter (e.g.: SetWindowText(unicode=1); please not extra xxxW -functions! thus one can easily virtualize apps with something like xyfunc(...,unicode=ucflag) * or: input-functions should also auto-run unicode when a significant string calling parameter is unicode - same as with filesystem-functions in normal python. Example: win32api.FindFiles(u"*") is same as FindFiles("*",unicode=1) and is better as FindFilesW("*") Thus existing ansi apps can be converted to unicode aware apps with minimum extra efforts. Robert ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Using win32com Constants
David Carter wrote: > Why is it that when I want to use a win32COM constant such as > acViewNormal in an MS Access COM automation session I find I > have to use some convoluted thing like: > > ComConstants = > win32com.client.constants.__dict__["__dicts__"][0] > viewtype = ComConstants['acViewNormal'] > > Am I missing something obvious? Are you calling Dispatch before referencing the constants? http://aspn.activestate.com/ASPN/docs/ActivePython/2.3/pywin32/html/com/ win32com/HTML/QuickStartClientCom.html "Makepy automatically installs all generated constants from a type library in an object called win32com.clients.constants. You do not need to do anything special to make these constants work, other than create the object itself (ie, in the example above, the constants relating to Word would automatically be available after the w=win32com.client.Dispatch("Word.Application") statement." Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] MS Access query error
Phill Atwood wrote: > intypes.com_error: (-2147352567, 'Exception occurred.', (0, > 'ADODB.Recordset', 'Operation is not allowed when the object is > closed.', 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, > -2146824584), None) IIRC, you need to set Cursorlocation before calling Recordcount. Google for more info. adUseClient = 3 rs.Cursorlocation = adUseClient Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] NT Service not re-startable after reboot
I have a Python service (vmpro_pager.py) which worked fine when I wrote it a month ago. You can see the complete source code here: http://projects.amor.org/misc/browser/vmpro_pager.py It runs an SMTP proxy to clean up SMTP messages from a sender which is not compliant with the SMTP spec. Today, we found out that the service was not running, and had not been running for some time; my best guess is since the first reboot after the service was installed. Attempts to remove the service via "vmpro_pager.py remove" failed, complaining that no such service was installed. After manually deleting the appropriate registry keys, I am able to run "vmpro_pager.py install" with no problems. However, starting the service from Windows Service Manager fails with the message, "Windows could not start the Voicemail Pro Email Fixup service on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 1." The Event Log contains a single Error event with the Description: "The Voicemail Pro Email Fixup service terminated with service-specific error 1." The PYS_SERVICE_STARTED message from SvcDoRun is *not* in the Event Log. Running the service via "vmpro_pager.py debug", however, works perfectly. Although I'm certainly open to answers of the type, "here's your problem..." ;) I'd like to also where I can insert hooks to return an error code more-meaningful than "1" in the future. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] NT Service not re-startable after reboot
in testFtpCommand INTERNET_SERVICE_FTP, 0, 0) error: (12029, 'InternetConnect', 'A connection with the server could not be established') == ERROR: testCallNamedPipe (test_win32pipe.CurrentUserTestCase) -- Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32\test\test_win32pipe.py", line 37, in testCallNamedPipe win32file.WriteFile(pipeHandle, "bar\0foo") error: (109, 'WriteFile', 'The pipe has been ended.') -- Ran 85 tests in 9.719s FAILED (errors=2) This would be nice to fix, but it's not the end of the world. If I can't get it working here, I'll just move it to a Linux box and go on my merry way... ;) Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] > -Original Message- > From: Mark Hammond [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 16, 2006 2:18 PM > To: Robert Brewer; python-win32@python.org > Subject: RE: [python-win32] NT Service not re-startable after reboot > > I'm afraid I've no idea. The first thing to check is that username > configured to use the service, and check that the service > does not rely on > any network shares or similar. Most service problems relate > to this (eg, > trying to run a service from a mapped drive as the LocalSystem account > doomed to failure. > > After that, I'd suggest importing win32traceutil early in > your program and > trying to determine if you module is being entered at all. > However, that > seems unlikely - once the service framework gets to the point > it tries to > import your module, it should also be at the point where it > can correctly > log any Python errors caused by the import and write them to > the event log. > > Good luck! > > Mark > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] Behalf Of Robert Brewer > > Sent: Friday, 17 March 2006 7:26 AM > > To: python-win32@python.org > > Subject: [python-win32] NT Service not re-startable after reboot > > > > > > I have a Python service (vmpro_pager.py) which worked fine > when I wrote > > it a month ago. You can see the complete source code here: > > http://projects.amor.org/misc/browser/vmpro_pager.py It runs an SMTP > > proxy to clean up SMTP messages from a sender which is not compliant > > with the SMTP spec. Today, we found out that the service was not > > running, and had not been running for some time; my best > guess is since > > the first reboot after the service was installed. > > > > Attempts to remove the service via "vmpro_pager.py remove" failed, > > complaining that no such service was installed. After > manually deleting > > the appropriate registry keys, I am able to run > "vmpro_pager.py install" > > with no problems. However, starting the service from Windows Service > > Manager fails with the message, "Windows could not start > the Voicemail > > Pro Email Fixup service on Local Computer. For more > information, review > > the System Event Log. If this is a non-Microsoft service, > contact the > > service vendor, and refer to service-specific error code > 1." The Event > > Log contains a single Error event with the Description: > "The Voicemail > > Pro Email Fixup service terminated with service-specific > error 1." The > > PYS_SERVICE_STARTED message from SvcDoRun is *not* in the Event Log. > > > > Running the service via "vmpro_pager.py debug", however, works > > perfectly. > > > > Although I'm certainly open to answers of the type, "here's your > > problem..." ;) I'd like to also where I can insert hooks to > return an > > error code more-meaningful than "1" in the future. > > > > > > Robert Brewer > > System Architect > > Amor Ministries > > [EMAIL PROTECTED] > > > > ___ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Runnin Python app as service with separate console
Title: RE: [python-win32] Runnin Python app as service with separate console Byron Morgan wrote: > I have a robust, stable Python script that runs 24-7, > crunching a telnet feed of real-time data. Problem is, > it has to run in a dos console window on the desktop. > I would like to run it as a service, and be able > connect to it and monitor performance with a separate > console (either gui or not) from time to time. I'm > hoping for advice on how to proceed. Making the script run as a service is not terribly difficult. Start by Googling for, say, "win32serviceutil.ServiceFramework" to get some sample code. Cut-n-paste should get you there. On the "separate console" front, I've given up on local, desktop-based solutions and now use a web-based terminal I wrote for use with CherryPy: http://projects.amor.org/misc/wiki/HTTPREPL Hope that helps, Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Python help for Access database
Shakir wrote: > I need help for inserting recods into the access database using python > script through ODBC. I can insert data without any problem if I hard > coded the run_Date field. But I need run_Date field should be > mytime. I really appreciate if anyone can help me. > > The script is as follows: > ... > mytime = time.strftime('%m/%d/%Y') > mytimeYMD = time.strftime('%Y%m%d') > conn = odbc.odbc("test1_Data") > cursor = conn.cursor() > > # data type in mdb is as follows: application -> Text, Run_Date -> > # Date, Run_dateYMD -> number, status -> Script > > cursor.execute("INSERT INTO local_cmgenadm > (Application,Run_Date,Run_DateYMD,status) values > (\'rimDev2PrdMdbDistrictPermit\',\'%s\', \'20060731\' , > \'Good\')")%mytime MS Access Dates are best input using the #date# syntax. Here's an example to convert a datetime.datetime object to that format: return ('#%s/%s/%s %02d:%02d:%02d#' % (value.month, value.day, value.year, value.hour, value.minute, value.second)) Should be easy enough to adapt to time.time. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] MySQL on Python 2.5
All, I am having trouble finding a module made to user MySQL on Pytho 2.5 on Windows. Could anyone point me to the right direction? The Windows MySQLdb will only install on my 2.4.3 version. Robert ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Win98 - exceptions.IOError: (13, 'Permission denied')
Hi to everyone, I have a Service, that runs on a WinXP machine. The service read a file on a Win98 machine and write the content in a file on the WinXP machine. After tree times I get the error message exceptions.IOError: (13, 'Permission denied'). The following things I have already tested: - The file on Win98 machine could be deleted, so the file is closed correctly. - Stop an restart the service on WinXP, will have no effect - Reboot the Win98 machine solve the problem for three times. So I have the same issue explained above. - I have changed the intervall from 5 sec to 1 minute. After ther first time I get the error message. - Using a Win2000 or WINXP machine instead of the Win98 machine. That works. But unfortunatly the PC to access is a Win98 and I have no influence to decide for upgrade. I can't figure out, what's the problem. This is the code to simulate my actual problem: # -*- coding: iso-8859-1 -*- import win32serviceutil import win32service import win32event import pywintypes import win32file import win32pipe import win32api import win32con import thread import ntsecuritycon import os import sys class MyService(win32serviceutil.ServiceFramework): """NT Service.""" _svc_name_ = "TCTest" _svc_display_name_ = "TCTest" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.stop_event = win32event.CreateEvent(None, 0, 0, None) self.overlapped = pywintypes.OVERLAPPED() self.overlapped.hEvent = win32event.CreateEvent(None,0,0,None) self.thread_handles = [] def SvcDoRun(self): import servicemanager servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '') ) while 1: datei = open(r'\\ipcwin98\test\test.txt', 'r') log = open(r'c:\log.txt', 'a') log.write(datei.read()) datei.close() log.close() if win32event.WaitForSingleObject(self.stop_event, 5000) == win32event.WAIT_OBJECT_0: break servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, '') ) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.stop_event) if __name__ == '__main__': win32serviceutil.HandleCommandLine(MyService) Thanks in advanced for your help. bye Robert -- http://www.dollinger.it signature.asc Description: Dies ist ein digital signierter Nachrichtenteil ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] MS Access: silent overflow failure
Hi all, The small demo script below makes ADO calls to a Microsoft Access (Jet) database via win32com. But it fails in a potentially dangerous way; "SELECT int * int;" can return None with no warning if the result is large enough. This can also occur if one or both of the operands is a column reference. The same SQL run as a Query inside the Access GUI works as expected. Manually changing one of the ints to a Single by appending ".0" works as expected. Any ideas about where I need to look next to find the cause of, and then fix, this behavior? Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] # demo_access_overflow.py import os import win32com.client adOpenForwardOnly = 0 adLockReadOnly = 1 dbname = "test.mdb" def create_db(): cat = win32com.client.Dispatch(r'ADOX.Catalog') cat.Create("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=%s;" % dbname) cat.ActiveConnection.Close() def fetch(query, conn): try: # Call conn.Open(query) directly, skipping win32com overhead. res = win32com.client.Dispatch(r'ADODB.Recordset') res.Open(query, conn, adOpenForwardOnly, adLockReadOnly) data = res.GetRows() finally: res.Close() return data if __name__ == '__main__': try: create_db() conn = win32com.client.Dispatch(r'ADODB.Connection') try: conn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=%s;" % dbname) # This works fine. assert fetch("SELECT 86400;", conn) == ((86400,),) # This fails because data is ((None,),) data = fetch("SELECT 62647 * 86400;", conn) assert (data == ((62647 * 86400,),)), data finally: conn.Close() finally: if os.path.exists(dbname): os.remove(dbname) ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] MS Access: silent overflow failure
Mark Hammond wrote: > Robert Brewer wrote: > > The small demo script below makes ADO calls to a Microsoft > > Access (Jet) > > database via win32com. But it fails in a potentially dangerous way; > > "SELECT int * int;" can return None with no warning if the result is > > large enough. This can also occur if one or both of the > > operands is a column reference. > > > > The same SQL run as a Query inside the Access GUI works as expected. > > Manually changing one of the ints to a Single by appending > > ".0" works as expected. > > > > Any ideas about where I need to look next to find the cause > > of, and then fix, this behavior? > > I'd suggest using VB to see if the behaviour is different > than with Python. If it is and we can narrow a test case to > a very small snippet, then we can probably sort out why. If > VB works the same, it is likely to be a "feature" of ADO as > implemented, and not much we can do. Below is a VB 4 demo (wow, that takes me back! :). The return value on overflow is a zero-length string. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ' demo_access_overflow.bas Attribute VB_Name = "Module1" Option Explicit Const adOpenForwardOnly = 0 Const adLockReadOnly = 1 Const dbname = "test.mdb" Sub create_db() Dim cat As New ADOX.Catalog cat.Create "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbname cat.ActiveConnection.Close End Sub Function fetch(query, conn) As String Dim res As New ADODB.Recordset res.Open query, conn, adOpenForwardOnly, adLockReadOnly, -1 Dim Data As Variant Data = res.GetRows(1, 0) fetch = Data(0, 0) res.Close End Function Sub Main() create_db Dim conn As New ADODB.Connection conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source='" & dbname & "'", "", "", -1 ' This works fine. Dim Data As String Data = fetch("SELECT 86400;", conn) If Data <> 86400 Then MsgBox (Data) ' This fails because data is "" Data = fetch("SELECT 62647 * 86400;", conn) If Data <> CStr(CSng(62647) * CSng(86400)) Then MsgBox (Data & " (len " & Len(Data) & ")") End If conn.Close Kill dbname End Sub ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Running CherryPy inside IIS
Tim Golden wrote: > Paul Johnston wrote: > > [... snip loads of IIS stuff about which I'm > blissfully ignorant ...] > > > Any suggestions will be much appreciated! Does anyone here > > have CherryPy working on Windows? > > Yup. I have it working standalone and (just today) > behind mod_python - and with mod_auth_sspi to boot. > But that obviously won't help if you're tied to IIS. That's my production setup, too (Apache 2, mod_python, and mod_auth_sspi), and is therefore a fundamental test case for CherryPy. IIS/ASP doesn't have nearly that level of testing (even though I wrote asp_gateway). I don't recommend it unless you have the time to debug the interaction between various versions of IIS, ASP, pywin32, and Python. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PyTime
Mark Hammond wrote: > Your solution seems to be to simply construct a datetime > object from the > pywintypes time object by way of attributes - eg: > > >>> from win32com.client import Dispatch > >>> import datetime > >>> xl=Dispatch("Excel.Application") > >>> d=xl.Range("A1").Value > >>> datetime.datetime(d.year, d.month, d.day, d.hour, > d.minute, d.second, > d.msec) > datetime.datetime(2065, 2, 3, 0, 0) Argle bargle...#$%^&* Wish I'd known about those attributes before I spent far too many hours trying to extract them back from float(d) [1]. Yet another lesson in the dangers of multiple documentation locations. Ah well, at least I learned something about Jet and SQL server internals. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] [1] http://projects.amor.org/geniusql/changeset/84 ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Apache & mod_python & win32com
[EMAIL PROTECTED] wrote: > I'm developing a web application using mod_python and the apache web > server. That application has to handle xml files and for that I'm using > win32com with with MSXML. > > My problem is, that apache spawns a new process / thread (not sure > wether ist a process or thread. I think it's a thread) On Windows, almost certainly a thread. Apache on Windows uses the "winnt" MPM, which is multithreaded, not multiprocess. > per http > request. So when multiple users generated requests "at the same time" > (new request before the first one is returned) I have multiple threads > running. And that's where my win32com code is crashing... > > Currently, for every request my code does the following (as an > example): > > return win32com.client.Dispatch("Msxml2.DOMDocument.6.0") > > To get an empty MSXSML DOM object. > > For multiple requests at the same time I get the following error: > > File "C:\Program Files\Apache Software > Foundation\Apache2.2\TCRExceptionManagerData\database_library\database. > py", line 24, in __init__ > self.__configFileSchema = self.__XSDSchemaCache() > > File "C:\Program Files\Apache Software > Foundation\Apache2.2\TCRExceptionManagerData\database_library\database. > py", line 1774, in __XSDSchemaCache > return win32com.client.Dispatch("MSXML2.XMLSchemaCache.6.0") > > File "C:\Program Files\Python25\lib\site- > packages\win32com\client\__init__.py", line 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > > File "C:\Program Files\Python25\lib\site- > packages\win32com\client\dynamic.py", line 98, in > _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > > File "C:\Program Files\Python25\lib\site- > packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > > com_error: (-2147221008, 'CoInitialize has not been called.', None, > None) > > I've read already a bit in this mailing list and someone mentioned that > one need to call pythoncom.CoInitialize() and > pythoncom.CoUninitialize(). But I don't know where exactly i should > call those functions and wether that'll solve my problem... Also, when > I do a 'import win32com.pythoncom' I get an error that the module > 'pythoncom' does not exist! > > I would be really happy if someone could help me and tell me how to > make my win32com work for multiple threads! As Alex mentioned, you need to call CoInitialize for each thread. Unfortunately, since Apache is creating the threads for you, you don't have a hook for events to run on thread startup. Instead, you have to watch threads as they go by and call CoInitialize ASAP. Best to do so with a try/finally in case something goes wrong: def handler(req): CoInitialize() try: process(req) return apache.OK finally: CoUninitialize() If for various reasons that can't be made to work (some components just aren't thread safe), another option would be to run all the COM calls in a single thread and use a Queue; request threads would call q.put(xml, reqid) and block, the COM thread would call q.get(), do the work, and shove the result into results[reqid]. Robert Brewer [EMAIL PROTECTED] ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Apache & mod_python & win32com
[EMAIL PROTECTED] wrote: > Thank you Rober & Alex for the answers :-) > But I must admit that I'm still bit uncertain about that whole issue. > As I understood apache it is creating a thread for every request > anyway, or not? (and yes, on windows the MPM winnt is used) As I understand it, Apache creates a pool of threads and re-uses them. From http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadsperchild: "This directive sets the number of threads created by each child process. The child creates these threads at startup and never creates more." > so wouldn't it be enough to just call CoInitialized() at the start of > my (mod_python) python-handler and CoUnitialize() and the end of my > handler? the try... finally you have added only for the case my script > would "crash", right? so that the CoUnitialize() is called in that case > as well? Yes, exactly. > The idea about the single thread and queue I don't really get to be > honest... what sort of object would be passed in the queue? And how > would I create that queue and the thread? Don't worry about it for now if the try/finally approach works. Ask again if you need to. > I guess you thinking of some > standard python modules (as there's probably a python module for > everything =))? :) Yup, there is a Queue module: http://docs.python.org/lib/module-Queue.html. Robert Brewer [EMAIL PROTECTED] ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Problems connecting to an MS Access (.mdb) file
Hello folks, At work I have to use an MS Access database. Actually it's two databases (or .mdb files, anyway): One is the "master" file that contains all the relevant data in tables, and the other one seems to act a s a "GUI client" which connects to the first one. Anyway, I have to go through dozens of data records each day, but for most of them whatever it is I'm having to do could be easily automated by a script, and that's what I'm trying to do. Tthe "master" DB resides on a networked drive, and I made a local copy to test out my script. When this was finished I pointed the script at the real master, but got the error message below. According to a password recovery tool I found on the Net (passwordrecovery4msaccess.jar), neither GUI nor master DB carry a password. Ah yes, of course I've spoken to the IT guy. He doesn't like my messing with his DB. But as this very stupid task eats up a lot of my work time, I want to hack it. Here's the error message: --- PythonWin 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript exec codeObject in __main__.__dict__ File "H:\ADB-python.py", line 8, in conn = odbc.odbc(conn_str) dbi.operation-error: [Microsoft][ODBC Microsoft Access Driver]Allgemeiner Fehler Registrierungsschlüssel 'Temporary (volatile) Jet DSN for process 0xfd0 Thread 0xfa4 DBC 0x349644 Jet' kann nicht geöffnet werden. in LOGIN --- Thanks, robert ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Setting service exit code on stop
Hello all, I am having a look through the C++ source code (in particular win32/src/PythonService.cpp), trying to deduce a way to have the Python service set the exit code on stop. It appears that on a successful stop, both exit codes (svc and win32) are set to 0, overriding any previously set value. Does anyone know of any way around this? If not, would this be a welcome feature request? Best regards, Rob ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32