[Tutor] Determine Filetype

admin at gg-lab.net admin at gg-lab.net
Fri Sep 18 22:10:59 CEST 2009


Ok, a good news for me:

i've modified my script, adding a:

import magic

line at the top of it. But I got this error:

No module named magic

Ok, so magic is not installed on GAE. I've then uploaded it and it
loaded succesfully. New error:

No module named _ctypes

And, reading the full debug i got this:

File "/base/python_dist/lib/python2.5/ctypes/__init__.py", line 10, in <module>
    from _ctypes import Union, Structure, Array

So, the __init__.py file of the GAE evinronment's ctypes library is
broken, as it's importing from a package that doesn't exist. Right?
Maybe i'm doing something wrong.

Thankyou

2009/9/18 admin at gg-lab.net <admin at gg-lab.net>:
> Oh, i'm sorry.
>
> I've read the README, but haven't noticed that
>
> m.from_buffer(open("testdata/test.pdf").read(1024))
>
> was exactly what i was looking for.
>
> Ok, i'll try it and let you know :D
>
> 2009/9/18 Kent Johnson <kent37 at tds.net>:
>> On Fri, Sep 18, 2009 at 2:21 PM, admin at gg-lab.net <admin at gg-lab.net> wrote:
>>> Hi Emile,
>>>
>>> that functions requires a filename/path.
>>
>> Did you even look at the link? There is a from_buffer() method also.
>>
>> Kent
>>
>>> 2009/9/18 Emile van Sebille <emile at fenx.com>:
>>
>>>> I'd take a look at python-magic at
>>>> http://hupp.org/adam/hg/python-magic/file/d3cd83e5a773 where the example
>>>> shows that you can do:
>>>>
>>>> # For MIME types
>>>>>>> mime = magic.Magic(mime=True)
>>>>>>> mime.from_file("testdata/test.pdf")
>>>> 'application/pdf'
>>
>


More information about the Tutor mailing list