From 6e3eefb997063971801bea933f319bb428b33fa5 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Fri, 18 Dec 2015 11:55:25 +0200 Subject: bitbake: toaster: Rework 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 prevents the download error from occurring. (Backport of dd957fe0f261db6481882fee0413f459425000c2 and dd957fe0f261db6481882fee0413f459425000c2 from master to Yocto 1.8) [YOCTO #8472] (Bitbake rev: b09966906ef054834f0b465f0c5a2a937b4c4a4c) Signed-off-by: Elliot Smith Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/toaster/bldcontrol/models.py | 34 -------------------------------- 1 file changed, 34 deletions(-) (limited to 'bitbake/lib/toaster/bldcontrol/models.py') diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py index 02cfaf7086..770ce40ae0 100644 --- a/bitbake/lib/toaster/bldcontrol/models.py +++ b/bitbake/lib/toaster/bldcontrol/models.py @@ -39,40 +39,6 @@ class BuildEnvironment(models.Model): created = models.DateTimeField(auto_now_add = True) updated = models.DateTimeField(auto_now = True) - - def get_artifact_type(self, path): - if self.betype == BuildEnvironment.TYPE_LOCAL: - try: - import magic - - # fair warning: this is a mess; there are multiple competeing and incompatible - # magic modules floating around, so we try some of the most common combinations - - try: # we try ubuntu's python-magic 5.4 - m = magic.open(magic.MAGIC_MIME_TYPE) - m.load() - return m.file(path) - except AttributeError: - pass - - try: # we try python-magic 0.4.6 - m = magic.Magic(magic.MAGIC_MIME) - return m.from_file(path) - except AttributeError: - pass - - try: # we try pip filemagic 1.6 - m = magic.Magic(flags=magic.MAGIC_MIME_TYPE) - return m.id_filename(path) - except AttributeError: - pass - - return "binary/octet-stream" - except ImportError: - return "binary/octet-stream" - raise Exception("FIXME: artifact type not implemented for build environment type %s" % be.get_betype_display()) - - def get_artifact(self, path): if self.betype == BuildEnvironment.TYPE_LOCAL: return open(path, "r") -- cgit v1.2.3-54-g00ecf