diff options
author | Elliot Smith <elliot.smith@intel.com> | 2015-10-06 20:05:22 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-11 05:33:04 +0100 |
commit | dd957fe0f261db6481882fee0413f459425000c2 (patch) | |
tree | 74b9f3e3483da9cf43c787705398578df8be303d | |
parent | ce9011a9dea4d4f8040170c28031cfbcadfbfd81 (diff) | |
download | poky-dd957fe0f261db6481882fee0413f459425000c2.tar.gz |
bitbake: toaster: Rationalise mimetype guessing to fix artifact downloads
Artifact download links were broken because the function to
get the mimetype for the artifact was incorrectly using the
underlying mimetype library. The function was also attached
to the build environment controller, which was unnecessary, as
we only support local controllers anyway.
Remove the mimetype getter on the build environment and
use the one in the view code instead. This works correctly
and prevents the download error from occurring.
[YOCTO #8369]
(Bitbake rev: 805fb2a9388c728600596e9b845a5c7eeaebd99c)
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/models.py | 34 | ||||
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 2 |
2 files changed, 1 insertions, 35 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py index f2493a8426..ab41105303 100644 --- a/bitbake/lib/toaster/bldcontrol/models.py +++ b/bitbake/lib/toaster/bldcontrol/models.py | |||
@@ -39,40 +39,6 @@ class BuildEnvironment(models.Model): | |||
39 | created = models.DateTimeField(auto_now_add = True) | 39 | created = models.DateTimeField(auto_now_add = True) |
40 | updated = models.DateTimeField(auto_now = True) | 40 | updated = models.DateTimeField(auto_now = True) |
41 | 41 | ||
42 | |||
43 | def get_artifact_type(self, path): | ||
44 | if self.betype == BuildEnvironment.TYPE_LOCAL: | ||
45 | try: | ||
46 | import magic | ||
47 | |||
48 | # fair warning: this is a mess; there are multiple competeing and incompatible | ||
49 | # magic modules floating around, so we try some of the most common combinations | ||
50 | |||
51 | try: # we try ubuntu's python-magic 5.4 | ||
52 | m = magic.open(magic.MAGIC_MIME_TYPE) | ||
53 | m.load() | ||
54 | return m.file(path) | ||
55 | except AttributeError: | ||
56 | pass | ||
57 | |||
58 | try: # we try python-magic 0.4.6 | ||
59 | m = magic.Magic(magic.MAGIC_MIME) | ||
60 | return m.from_file(path) | ||
61 | except AttributeError: | ||
62 | pass | ||
63 | |||
64 | try: # we try pip filemagic 1.6 | ||
65 | m = magic.Magic(flags=magic.MAGIC_MIME_TYPE) | ||
66 | return m.id_filename(path) | ||
67 | except AttributeError: | ||
68 | pass | ||
69 | |||
70 | return "binary/octet-stream" | ||
71 | except ImportError: | ||
72 | return "binary/octet-stream" | ||
73 | raise Exception("FIXME: artifact type not implemented for build environment type %s" % self.get_betype_display()) | ||
74 | |||
75 | |||
76 | def get_artifact(self, path): | 42 | def get_artifact(self, path): |
77 | if self.betype == BuildEnvironment.TYPE_LOCAL: | 43 | if self.betype == BuildEnvironment.TYPE_LOCAL: |
78 | return open(path, "r") | 44 | return open(path, "r") |
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 6e5815595f..839ee78f97 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2981,7 +2981,7 @@ if True: | |||
2981 | if file_name is None: | 2981 | if file_name is None: |
2982 | raise Exception("Could not handle artifact %s id %s" % (artifact_type, artifact_id)) | 2982 | raise Exception("Could not handle artifact %s id %s" % (artifact_type, artifact_id)) |
2983 | else: | 2983 | else: |
2984 | content_type = b.buildrequest.environment.get_artifact_type(file_name) | 2984 | content_type = MimeTypeFinder.get_mimetype(file_name) |
2985 | fsock = b.buildrequest.environment.get_artifact(file_name) | 2985 | fsock = b.buildrequest.environment.get_artifact(file_name) |
2986 | file_name = os.path.basename(file_name) # we assume that the build environment system has the same path conventions as host | 2986 | file_name = os.path.basename(file_name) # we assume that the build environment system has the same path conventions as host |
2987 | 2987 | ||