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