ppwwyyxx/SoPaper

Test for file type on windows

moissinac opened this issue · 3 comments

Code
s = Popen('file "{0}"'.format(f.name),
stdout=PIPE, shell=True).stdout.read()
is platform specific
I suggest to add a switch in the config and to use
if ukconfig.USE_PYPDF2:
try:
fo = open(f.name, "rb")
PyPDF2.PdfFileReader(fo)
s = "PDF document"
except PyPDF2.utils.PdfReadError:
s = "invalid PDF file"
finally:
fo.close()
else:
s = Popen('file "{0}"'.format(f.name),
stdout=PIPE, shell=True).stdout.read()

If you enable magic, it shouldn't go to that line.

Could you install python-magic?
Just add it as a dependency.

I will try. But python-magic seems to be problematic to install on windows (see https://github.com/ahupp/python-magic) while pypdf2 is working and straightforward to install