chiark / gitweb /
Support both debian's and pypi's python-magic libraries, which are different...
authormoparisthebest <android@moparisthebest.org>
Mon, 17 Feb 2014 03:42:16 +0000 (22:42 -0500)
committermoparisthebest <android@moparisthebest.org>
Mon, 17 Feb 2014 03:42:16 +0000 (22:42 -0500)
fdroidserver/common.py
setup.py

index 4fc6de6b205c364b1a284ea1f2819d79041fef78..5e424dae822716a6b25961a2249fd65457f183f3 100644 (file)
@@ -1136,8 +1136,11 @@ def scan_source(build_dir, root_dir, thisbuild):
     scanignore = getpaths('scanignore')
     scandelete = getpaths('scandelete')
 
-    ms = magic.open(magic.MIME_TYPE)
-    ms.load()
+    try:
+        ms = magic.open(magic.MIME_TYPE)
+        ms.load()
+    except AttributeError:
+        ms = None
 
     def toignore(fd):
         for i in scanignore:
@@ -1187,7 +1190,7 @@ def scan_source(build_dir, root_dir, thisbuild):
                 if suspect in curfile.lower():
                     handleproblem('usual supect', fd, fp)
 
-            mime = ms.file(fp)
+            mime = magic.from_file(fp, mime=True) if ms is None else ms.file(fp)
             if mime == 'application/x-sharedlib':
                 handleproblem('shared library', fd, fp)
             elif mime == 'application/x-archive':
@@ -1204,7 +1207,8 @@ def scan_source(build_dir, root_dir, thisbuild):
                     if 'DexClassLoader' in line:
                         handleproblem('DexClassLoader', fd, fp)
                         break
-    ms.close()
+    if ms is not None:
+        ms.close()
 
     # Presence of a jni directory without buildjni=yes might
     # indicate a problem (if it's not a problem, explicitly use
index 43a7afe02edb617fd9d50497df04b1523520b3ab..7bbec283b2a6b7128f02cd69975256cb2bdecdac 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,7 @@ setup(name='FDroidServer',
           'fdroid-icon.png']),
         ],
       install_requires=[
+        'python-magic',
         'PIL',
         ],
       classifiers=[