pyTivo Discussion Forum Forum Index pyTivo Discussion Forum
Answers and the development of pyTivo a TiVo transcoding server
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tip: Python error messages are usually readable

 
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Support
 View previous topic :: View next topic  
Author Message
wmcbrine



Joined: 04 Jan 2008
Posts: 2330
Location: Maryland

PostPosted: Sat Feb 23, 2008 3:22 am    Post subject: Tip: Python error messages are usually readable Reply with quote

I see some requests for help from people who include the Python "traceback", with the error explained right in it. I suspect some are overlooking it, partly because the most relevant part is at the end -- the rest of the lines just let you follow the path of execution through the program -- and partly because people are so used to cryptic error messages that they just assume they won't be able to read it. But take a look at this example:

Code:
Traceback (most recent call last):
  File "/usr/local/tivo/pyTivo/pyTivo.py", line 11, in <module>
    httpd.add_container(section, settings)
  File "/usr/local/tivo/pyTivo/httpserver.py", line 22, in add_container
    settings['content_type'] = GetPlugin(settings['type']).CONTENT_TYPE
  File "/usr/local/tivo/pyTivo/plugin.py", line 13, in GetPlugin
    module = __import__(module_name, globals(), locals(), name)
  File "/usr/local/tivo/pyTivo/plugins/photo/photo.py", line 28, in <module>
    import Image
ImportError: No module named Image


I'm picking on this one because KRKeegan just did a patch to replace it with "Photo Plugin Error: The Python Imaging Library is not installed" and suppress the traceback. I don't really disagree with that, but I think this is the sort of error message that the average user should be able to tackle as it is. Let's take a look at that last line:

Code:
ImportError: No module named Image


That's the whole error, really, and it's in fairly plain English. It says that it tried to load a module named "Image", and couldn't find it. Well, you might not know what a module is, or where the Image module comes from, but it probably won't take you long to find out. What does the rest of the traceback tell us? Moving upwards from the bottom:

Code:
File "/usr/local/tivo/pyTivo/plugins/photo/photo.py", line 28, in <module>
    import Image


Here's the exact line of the exact file that caused the problem. "import Image" doesn't further illuminate anything, but we can see that it's the photo plugin (photo.py) that wants the Image module.

In this case, the rest of the traceback isn't really useful, but it might be in some circumstances. You can see that it was the GetPlugin() function that tried to load photo.py, and in turn the add_container() function that called GetPlugin().

_________________
My pyTivo fork . My page
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Site is in NO WAY affiliated with TiVo Inc

Powered by phpBB © 2001, 2005 phpBB Group
phpBB SEO

Get pytivo at SourceForge.net. Fast, secure and Free Open Source software downloads
[ Time: 0.1421s ][ Queries: 12 (0.0130s) ][ GZIP on - Debug on ]