allow no magic
This commit is contained in:
@@ -3,7 +3,10 @@ from datetime import datetime
|
||||
from flask import current_app as app
|
||||
import requests
|
||||
import re
|
||||
import magic
|
||||
try:
|
||||
import magic
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
from urllib.request import pathname2url
|
||||
from urllib.request import urlparse
|
||||
@@ -60,7 +63,11 @@ def version_date(full_path):
|
||||
|
||||
|
||||
def file_mime(filename):
|
||||
return magic.from_file(filename, mime = True)
|
||||
try:
|
||||
return magic.from_file(filename, mime = True)
|
||||
except NameError:
|
||||
# magic not imported
|
||||
return "NA"
|
||||
|
||||
def file_stat(path, filename):
|
||||
full_path = os.path.join(path, filename)
|
||||
|
||||
Reference in New Issue
Block a user