From 42afeb422ea0a5e226cef586353d194d0339bbd7 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Thu, 2 Oct 2014 17:58:15 +0100 Subject: bitbake: toastergui: Various fixes for projects, layers and targets page This is a combined set of fixes for the project, layers and targets pages in the project section of toaster. The fixes correct behaviour and look in various parts of the page, including submitting XHR commands and updating the DOM with the correct info. (Bitbake rev: 96d7738f964784871c928c376cb9fbc9a275cf00) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/bldcontrol/models.py | 33 +++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 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 f72fb8fbc9..e643d08603 100644 --- a/bitbake/lib/toaster/bldcontrol/models.py +++ b/bitbake/lib/toaster/bldcontrol/models.py @@ -42,11 +42,34 @@ class BuildEnvironment(models.Model): def get_artifact_type(self, path): if self.betype == BuildEnvironment.TYPE_LOCAL: - import magic - m = magic.open(magic.MAGIC_MIME_TYPE) - m.load() - return m.file(path) - raise Exception("FIXME: not implemented") + 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" def get_artifact(self, path): if self.betype == BuildEnvironment.TYPE_LOCAL: -- cgit v1.2.3-54-g00ecf