From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id C4B28E00C0B; Mon, 28 Sep 2015 02:05:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [192.55.52.88 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 731ACE00349 for ; Mon, 28 Sep 2015 02:05:35 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 28 Sep 2015 02:05:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,602,1437462000"; d="scan'208";a="778822459" Received: from linux.intel.com ([10.23.219.25]) by orsmga001.jf.intel.com with ESMTP; 28 Sep 2015 02:05:35 -0700 Received: from linux.intel.com (vmed.fi.intel.com [10.237.72.51]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTP id 17FCF6A4083; Mon, 28 Sep 2015 02:04:38 -0700 (PDT) Date: Mon, 28 Sep 2015 12:05:30 +0300 From: Ed Bartosh To: Elliot Smith Message-ID: <20150928090530.GB7533@linux.intel.com> References: <1443100461-27664-1-git-send-email-elliot.smith@intel.com> MIME-Version: 1.0 In-Reply-To: <1443100461-27664-1-git-send-email-elliot.smith@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.21 (2010-09-15) Cc: toaster@yoctoproject.org Subject: Re: [review-request][PATCH] toaster: Rationalise mimetype guessing to fix artifact downloads X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: ed.bartosh@linux.intel.com List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 09:05:40 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Elliot, The patch looks great! Thanks you! Acked-by: Ed Bartosh On Thu, Sep 24, 2015 at 02:14:21PM +0100, Elliot Smith wrote: > 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] > > Signed-off-by: Elliot Smith > --- > bitbake/lib/toaster/bldcontrol/models.py | 34 -------------------------------- > bitbake/lib/toaster/toastergui/views.py | 2 +- > 2 files changed, 1 insertion(+), 35 deletions(-) > > diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py > index b61de58..c577b10 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" % self.get_betype_display()) > - > - > def get_artifact(self, path): > if self.betype == BuildEnvironment.TYPE_LOCAL: > return open(path, "r") > diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py > index 8689a12..2ec0197 100755 > --- a/bitbake/lib/toaster/toastergui/views.py > +++ b/bitbake/lib/toaster/toastergui/views.py > @@ -2797,7 +2797,7 @@ if True: > if file_name is None: > raise Exception("Could not handle artifact %s id %s" % (artifact_type, artifact_id)) > else: > - content_type = b.buildrequest.environment.get_artifact_type(file_name) > + content_type = MimeTypeFinder.get_mimetype(file_name) > fsock = b.buildrequest.environment.get_artifact(file_name) > file_name = os.path.basename(file_name) # we assume that the build environment system has the same path conventions as host > > -- > Elliot Smith > Software Engineer > Intel OTC > > --------------------------------------------------------------------- > Intel Corporation (UK) Limited > Registered No. 1134945 (England) > Registered Office: Pipers Way, Swindon SN3 1RJ > VAT No: 860 2173 47 > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. > > -- > _______________________________________________ > toaster mailing list > toaster@yoctoproject.org > https://lists.yoctoproject.org/listinfo/toaster -- -- Regards, Ed