How to use gnomevfs.get_mime_type()?
Python gnome binding have gnomevfs
module that theoretically can get MIME types. But calling gnomevfs.get_mime_type()
with any name other than "/dev/null" raises err开发者_开发知识库or "RuntimeError: there was an error reading the file". For example:
import gnomevfs
gnomevfs.get_mime_type( "/tmp/a.py" )
gnomevfs.get_mime_type( "file://tmp/a.py" )
gnomevfs.get_mime_type( "file:///tmp/a.py" )
gnomevfs.get_mime_type( "file://./tmp/a.py" )
This all fails. With any file / folder name except "/dev/null" :(. /tmp/a.py
exists and acessible. Any suggestions?
It works for me. Have you tried with other files in other directories? Are you sure that the user under which Python is being run has access to /tmp/a.py?
精彩评论