try to fix magic

pull/2/head
Raphaël Vinot 2015-11-05 01:41:45 +01:00
parent 531ab43dae
commit 9079eac90a
3 changed files with 13 additions and 6 deletions

View File

@ -16,6 +16,7 @@ addons:
- p7zip-full
install:
- pip install git+https://github.com/Rafiot/python-magic.git@travis
- sudo add-apt-repository ppa:fontforge/fontforge --yes
- sudo add-apt-repository ppa:coolwanglu/pdf2htmlex --yes
- sudo apt-get update -qq
@ -28,7 +29,6 @@ install:
- make
- sudo make install
- popd
- pip install python-magic
- pip install lxml
- pip install officedissector
- if [ $(python -c 'import sys; print(sys.version_info.major)') == '2' ]; then pip install oletools olefile ; fi

View File

@ -50,9 +50,12 @@ class File(FileBase):
self.main_type = ''
self.main_type = ''
try:
mimetype = magic.from_file(src_path, mime=True).decode("utf-8")
mimetype = magic.from_file(src_path, mime=True)
try:
mimetype = mimetype.decode("utf-8")
except:
pass
except Exception as e:
print('************************** BROKEN', self.src_path)
print('************************** BROKEN', self.src_path, e)
self.make_dangerous()
return

View File

@ -17,9 +17,13 @@ class FileSpec(FileBase):
super(FileSpec, self).__init__(src_path, dst_path)
a, self.extension = os.path.splitext(self.src_path)
try:
self.mimetype = magic.from_file(self.src_path, mime=True).decode("utf-8")
except:
print('************************** BROKEN', self.src_path)
self.mimetype = magic.from_file(self.src_path, mime=True)
try:
self.imetype = self.mimetype.decode("utf-8")
except:
pass
except Exception as e:
print('************************** BROKEN', self.src_path, e)
class KittenGroomerSpec(KittenGroomerBase):