Looking a device up in the Running Object Table
I'm looking to disable Windows autoplay for a particular device. There's a registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\CancelAutoplay\CLSID) that will turn off autoplay for listed devices, but one must provide the device's CLSID as it appears in the ROT. I use the wmi module (http://tgolden.sc.sabren.com/python/wmi.html) to discover the device's GUID, but I don't know enough about COM to look it up in the ROT. Is there a difference between the GUID and the CLSID in the ROT, or am I just not using the registry correctly? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem overriding sys.excepthook
Try/except sounds like the way to go. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem overriding sys.excepthook
Thank you for a fine explanation Pat, that clears things up very nicely. I have one remaining question which I imagine amounts to taste. What is the superior method of exception handling: A) To, as you suggest above, import the code as a module from within a program with special exception handling code. or B) To pipe sys.stderr to a file and keep the OS on the lookout for a non-zero errorlevel (via a batch file or some such) and then launch another Python script to further handle the error output. My goal is to upload error reports to a server. My criteria for preference are first performance and second conformance with Python style. Any overwhelming opinion or alternative solution? Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem overriding sys.excepthook
Forgive my ignorance, but I'm not quite sure what you mean. I tried importing the traceback module at the beginning of the script, but that didn't make a difference. Could you provide example code to illustrate your comment? Thanks. -LTM -- http://mail.python.org/mailman/listinfo/python-list
Problem overriding sys.excepthook
Yo all, I'm getting into Python for the first time and I'm really having a blast. I've hit a bit of a snag and was wondering if someone could lend some insight. Here be the code: import sys def myexcepthook(type, value, tb): import traceback rawreport = traceback.format_exception(type, value, tb) report = '\n'.join(rawreport) errorlog = open('error.log','a') errorlog.write(('%s\n' + '-'*30 + '\n\n') % report) errorlog.close() sys.excepthook = myexcepthook Now here's the trouble: if I enter that line-by-line into the interpreter in interactive mode, the custom exception hook will handle all exceptions, but if I put that in a script that I run from the shell, it only catches some exceptions. For example, it would catch an undefined name, like if I just put: spam into the program above, the override would work. But if I made a syntactical error, like: 1 = spam then it would fall to the standard sys.excepthook. Is there some lazy evaluation that I don't know about? I'm on Windows, if that makes a difference. Thank for the help. -LTM -- http://mail.python.org/mailman/listinfo/python-list