Hello all, I am developing an application that, amongst other things, exports files and then launches them in their associated applications using os.startfile. It also uses webbrowser.open, which I see uses os.startfile.
Everything works on my PC and on all the other PCs in the office that I have tested on. However, when we released our first version, a few users reported unhandled exceptions that seem to be coming from os.startfile. Here are some examples: Traceback (most recent call last): File "link_planner\wxapp\main_frame.pyc", line 1505, in _on_csv File "link_planner\utils\platform_win32.pyc", line 17, in openfile WindowsError: [Error 2] The system cannot find the file specified: 'c:\\docume~1\\admin\\locals~1\\temp\\tmpjotxlk.csv' Traceback (most recent call last): File "link_planner\wxapp\main_frame.pyc", line 1528, in _on_google_earth File "link_planner\utils\platform_win32.pyc", line 17, in openfile WindowsError: [Error -2147024809] The parameter is incorrect: 'c:\\docume~1\\bfults\\locals~1\\temp\\tmphjyfy-.kml' Traceback (most recent call last): File "link_planner\wxapp\html_window.pyc", line 7, in OnLinkClicked File "link_planner\wxapp\about_frame.pyc", line 41, in _on_link_clicked File "webbrowser.pyc", line 60, in open File "webbrowser.pyc", line 516, in open WindowsError: [Error 2] The system cannot find the file specified: u'http://www.motorola.com/ptp' In the last instance, the user said the problem went away when he changed his default browser from firefox to IE, so it may be a red herring, but I'd like to be sure. In the first two cases, I use tempfile.mkstemp to generate the temporary files, so I am fairly sure that they exist. I've searched for any information about similar issues, and this is what I've found: This guy sounds like he has exactly the same problem, but there is no solution given: http://groups.google.co.uk/group/comp.lang.python/browse_thread/thread/d d86ba0e6420a2b4/75c8cacd8e6c06ed This recipe describes os.startfile failing for URLs: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334665 It includes a link to another page saying that ShellExecute doesn't work from a multi-threaded apartment. I don't think that is my problem here, as I am not using multiple threads, and I'm not (as far as I am aware) using COM anywhere. I made a quick test, and the error message I get is different: WindowsError: [Error 14007] The requested lookup key was not found in any active activation context: 'http://www.python.org'. I think my next step is going to be reimplementing os.startfile in python and adding more logging, but I just wondered whether anyone else had ever had problems with os.startfile? BTW, all this is from Python 2.5.1, but the application has been packaged using py2exe, in case that makes a difference. Thanks a lot for any suggestions, Simon King _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32