Regression: Can't attach file #213

Closed
murks opened this Issue Dec 27, 2011 · 13 comments

Comments

Projects
None yet
3 participants

murks commented Dec 27, 2011

Attempting to attach a zip file leads to this:

Error: 'module' object has no attribute 'MAGIC_MIME_TYPE',
check the log for details

Of course there's no log due to the logging bug. Why does attaching stuff need MIME type stuff?

Owner

pazz commented Dec 28, 2011

On Dec 28, 2011 12:04 AM, "murks" <
reply@reply.github.com>
wrote:

Attempting to attach a zip file leads to this:

Error: 'module' object has no attribute 'MAGIC_MIME_TYPE',
check the log for details

damn. you don't have the right python-magic version. but i dont know the
exact dependency. will need to investigate this.

Of course there's no log due to the logging bug.
aye :/
On Dec 28, 2011 12:04 AM, "murks" <
reply@reply.github.com>
wrote:

Attempting to attach a zip file leads to this:

Error: 'module' object has no attribute 'MAGIC_MIME_TYPE',
check the log for details

Of course there's no log due to the logging bug. Why does attaching stuff
need MIME type stuff?


Reply to this email directly or view it on GitHub:
#213

Owner

pazz commented Dec 28, 2011

i found out how to delegate issues :D
@teythoon: I will make this yours as the libmagic stuff was your idea & code...
do we know the exact dependency here?

@ghost ghost assigned teythoon Dec 28, 2011

murks commented Dec 29, 2011

There are a number of results for 'magic' on this page: https://pypi.python.org/pypi?%3Aaction=search&term=magic&submit=search

The implementation where I couldn't add attachements was: http://darwinsys.com/file/
I tried it with http://pypi.python.org/pypi/python-magic/, but all I get is an empty buffer (instead of 125 messages).

murks commented Dec 29, 2011

The empty buffer thing seems to be something else, I don't know what it is, but it sure isn't good.

$ notmuch search tag:inbox AND NOT tag:killed
returns a number of threads and messages, they're simply not shown in alot.
The funky part: some search results are shown, the problem seems to be pretty random. Sometimes after a few successful searches the results are shown. Example:
[search] for "tag:inbox" (125 threads) -> not shown
[search] for "killed" (887 threads) -> shown
[search] for "tag:unread" (57735 threads) -> shown
[search] for "tag:inbox" (125 threads) -> shown

I don't get it..

murks commented Dec 29, 2011

The weird buffer bug seems to be gone again... I guess it was some python weirdness.
http://pypi.python.org/pypi/python-magic/ doesn't allow me to add an attachment either.

Owner

pazz commented Dec 29, 2011

this empty buffer stuff is certainly unrelated and deserves an issue of its own.
I have the feeling that your (hopefully not all or arch's) python environment is broken somehow.

apart from this, we do need to fix the magic dependency of course

Owner

pazz commented Dec 29, 2011

this module uses a completely different syntax as the one we use: http://pypi.python.org/pypi/python-magic/
Apparently, i'm using v 5.04 of the darvinsys version: ftp://ftp.astron.com/pub/file/

some more info on python-magic on my box:

pazz@brick:~$ aptitude show python-magic
Package: python-magic                    
New: yes
State: installed
Automatically installed: no
Version: 5.04-5ubuntu3
Priority: extra
Section: python
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Uncompressed Size: 147 k
Depends: libc6 (>= 2.2.5), libmagic1, python2.7 | python2.6, python (>= 2.6), python (< 2.8)
Suggests: python-magic-dbg
Conflicts: python-magic
Provides: python2.6-magic, python2.7-magic
Description: File type determination library using "magic" numbers (Python bindings)
 This library can be used to classify files according to magic number tests. It implements the
 core functionality of the file command. 

 This package contains the Python bindings.
Homepage: http://www.darwinsys.com/file/
pazz@brick:~$ ipython
Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import magic

In [2]: magic ?
Type:       module
Base Class: <type 'module'>
String Form:    <module 'magic' from '/usr/lib/python2.7/dist-packages/magic.so'>
Namespace:  Interactive
File:       /usr/lib/python2.7/dist-packages/magic.so
Docstring:
    <no docstring>

no module, just the .so file ?!?

pazz@brick:~$ locate magic.py
/usr/lib/python2.6/dist-packages/IPython/kernel/magic.py
/usr/lib/python2.6/dist-packages/IPython/kernel/core/magic.py
/usr/lib/python2.6/dist-packages/IPython/tests/test_magic.py
/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/py/magic.py
/usr/lib/python2.7/dist-packages/IPython/kernel/magic.py
/usr/lib/python2.7/dist-packages/IPython/kernel/magic.pyc
/usr/lib/python2.7/dist-packages/IPython/kernel/core/magic.py
/usr/lib/python2.7/dist-packages/IPython/kernel/core/magic.pyc
/usr/lib/python2.7/dist-packages/IPython/tests/test_magic.py
/usr/lib/python2.7/dist-packages/IPython/tests/test_magic.pyc
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/py/magic.py
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/py/magic.pyc
/usr/share/hplip/base/magic.py
/usr/share/hplip/base/magic.pyc
/usr/share/pyshared/IPython/kernel/magic.py
/usr/share/pyshared/IPython/kernel/core/magic.py
/usr/share/pyshared/IPython/tests/test_magic.py

there seems to be a local libmagic module in hplib (cups?)

murks commented Dec 29, 2011

The version I previously tried was 5.03, but I found that the last released version is 5.09. I updated to 5.09 and it seems to work. For fun, here's my output of the equivalent commands:

$ pacman -Qi python-magic
Name : python-magic
Version : 5.09-1
URL : http://darwinsys.com/file/
Licenses : custom
Groups : None
Provides : None
Depends On : file python2
Optional Deps : None
Required By : None
Conflicts With : None
Replaces : None
Installed Size : 44.00 K
Packager : Unknown Packager
Architecture : x86_64
Build Date : Thu 29 Dec 2011 02:13:54 PM CET
Install Date : Thu 29 Dec 2011 02:14:00 PM CET
Install Reason : Explicitly installed
Install Script : No
Description : Python bindings to allow you to access the libmagic api

$ ipython2
Python 2.7.2 (default, Nov 21 2011, 17:25:27)
Type "copyright", "credits" or "license" for more information.

IPython 0.12 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: import magic

In [2]: magic ?
Type: module
Base Class: <type 'module'>
String Form:<module 'magic' from '/usr/lib/python2.7/lib-dynload/magic.py'>
Namespace: Interactive
File: /usr/lib/python2.7/lib-dynload/magic.py
Docstring: Python bindings for libmagic

$ locate magic.py
/usr/lib/python2.7/lib-dynload/magic.py
/usr/lib/python2.7/site-packages/IPython/core/magic.py
/usr/lib/python2.7/site-packages/IPython/core/tests/test_magic.py
/usr/lib/python2.7/site-packages/IPython/extensions/parallelmagic.py
/usr/lib/python2.7/site-packages/IPython/extensions/storemagic.py
/usr/lib/python2.7/site-packages/IPython/lib/tests/test_irunner_pylab_magic.py
/usr/share/hplip/base/magic.py

Well, the install path for the module seems a bit weird here, but that may just be the packagers fault.
I can attach a file now, thanks. Maybe 5.04 is the minimal version for some reason.

Owner

pazz commented Dec 29, 2011

its really unfortunate that there is a 3rd party lib at pypi called like the package for the original™ bindings in debian.

so: dependencies for setup.py and debians packages:

for deb it should be python-magic >=5.04.

Owner

pazz commented Dec 31, 2011

cf ahupp/python-magic#8
https://bugs.launchpad.net/lalita/+bug/504560

no idea how to proceed here. apparently there are at leas two implementations of ctypes based libmagic modules
packaged as "python-magic" in various distris and the equally named module on pypi is depricated.

murks commented Jan 1, 2012

Well, 5.04 from http://darwinsys.com/file/ is apparently the earliest working version. I think you should include this information so packagers and people who build it themselves can make sure that they use the correct library.

Owner

pazz commented Jan 1, 2012

right. the question was more or less what to do in the setup.py about this.
I will update the INSTALL file wrt the url and version of python-magic for a start..

Owner

pazz commented Mar 6, 2012

this dependency is now documented in INSTALL and docs/installation.rst

@pazz pazz closed this Mar 6, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment