diff options
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 15 | ||||
-rw-r--r-- | bitbake/toaster-requirements.txt | 1 |
2 files changed, 11 insertions, 5 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index db791cfd80..6e5815595f 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -47,19 +47,26 @@ import json | |||
47 | from os.path import dirname | 47 | from os.path import dirname |
48 | from functools import wraps | 48 | from functools import wraps |
49 | import itertools | 49 | import itertools |
50 | import mimetypes | ||
50 | 51 | ||
51 | import magic | ||
52 | import logging | 52 | import logging |
53 | 53 | ||
54 | logger = logging.getLogger("toaster") | 54 | logger = logging.getLogger("toaster") |
55 | 55 | ||
56 | class MimeTypeFinder(object): | 56 | class MimeTypeFinder(object): |
57 | _magic = magic.Magic(flags = magic.MAGIC_MIME_TYPE) | 57 | # setting this to False enables additional non-standard mimetypes |
58 | # to be included in the guess | ||
59 | _strict = False | ||
58 | 60 | ||
59 | # returns the mimetype for a file path | 61 | # returns the mimetype for a file path as a string, |
62 | # or 'application/octet-stream' if the type couldn't be guessed | ||
60 | @classmethod | 63 | @classmethod |
61 | def get_mimetype(self, path): | 64 | def get_mimetype(self, path): |
62 | return self._magic.id_filename(path) | 65 | guess = mimetypes.guess_type(path, self._strict) |
66 | guessed_type = guess[0] | ||
67 | if guessed_type == None: | ||
68 | guessed_type = 'application/octet-stream' | ||
69 | return guessed_type | ||
63 | 70 | ||
64 | # all new sessions should come through the landing page; | 71 | # all new sessions should come through the landing page; |
65 | # determine in which mode we are running in, and redirect appropriately | 72 | # determine in which mode we are running in, and redirect appropriately |
diff --git a/bitbake/toaster-requirements.txt b/bitbake/toaster-requirements.txt index c4a2221553..1d7d21b331 100644 --- a/bitbake/toaster-requirements.txt +++ b/bitbake/toaster-requirements.txt | |||
@@ -2,5 +2,4 @@ Django==1.6 | |||
2 | South==0.8.4 | 2 | South==0.8.4 |
3 | argparse==1.2.1 | 3 | argparse==1.2.1 |
4 | wsgiref==0.1.2 | 4 | wsgiref==0.1.2 |
5 | filemagic==1.6 | ||
6 | beautifulsoup4>=4.4.0 | 5 | beautifulsoup4>=4.4.0 |