Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B87ADE01153; Tue, 2 Aug 2016 06:32:19 -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=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.220.49 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id A880FE00F6A for ; Tue, 2 Aug 2016 06:32:17 -0700 (PDT) Received: by mail-pa0-f49.google.com with SMTP id pp5so63590269pac.3 for ; Tue, 02 Aug 2016 06:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WoGnNGdwEHgRuKReI5VAnhQD/BLat62GLHIeMo+/xyM=; b=zUxFTYdgP0hEtaEtEYBFJfDbJ3r0wX2zlPygb94gnE3T4+rtuc2ww4aoX4+4RPcRDh xzZzOn4vHY4mJq5sKwKgqqh0aDceQoVKANjbW/i07lL/DHRQNPn/BAc/S08WpcsQY/oz cvlJve5JMECGqioy0+Ji2N5Kqapzg7XQRycOhzLnIBhkm2izTXUaahL29tKxUPnFcChN RlOcLpYZJKMatmjPazi4qQbRVTfRM41ZjTY8Y+xVqjTSPKXBzlyBtI1wMF5LBssaUlao VGhjitf1+DSvdNi1G4ie1yC3OW//M3tVfwXHHoQPiQUMaxg0bnOpwIlfLdf11O7yJ97+ VTIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WoGnNGdwEHgRuKReI5VAnhQD/BLat62GLHIeMo+/xyM=; b=CeAAQMSftE5QiFzVH2EfZMRzWO0bB9YatNioD5LaJSFoN6aG+YvXWtLgc4OyJE7oHX Q/qU84O9ljwJUT6EoItxJhzUci0ZjDQzmE+aPbYHTfDIt+QAGcvj2vqSlFG6OFPtNIKL NOPw3qBKM3CEgjKw5BsZa91UZ+MhnJyhNrroUs6ynGN7wzWqL9iwUGUk2+YCLbx3F86i 4fggA0bH2d/8GPvvAl9X2Sej+CPkDFp6vYuyGUk6ivuzgLNWIn5v7bhaqx6HxxmNiKhS wp4HIbre9kghN4vdc/lihYbFUCoG4h7VM4MgfYDHE24VBYPpTQNGtrb6kQAkB6V9av0i FejQ== X-Gm-Message-State: AEkoouvhVzcNCYNj8HAItEIeYZfqjKr2j54KGV2ZnVN+hqTqN/f5hiiUbgCvSzycBzMeP/E+ X-Received: by 10.66.164.227 with SMTP id yt3mr106616363pab.117.1470144736666; Tue, 02 Aug 2016 06:32:16 -0700 (PDT) Received: from orion.ger.corp.intel.com (fmdmzpr02-ext.fm.intel.com. [192.55.55.37]) by smtp.gmail.com with ESMTPSA id s1sm5049532paz.47.2016.08.02.06.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 06:32:16 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 2 Aug 2016 14:32:03 +0100 Message-Id: <1470144726-5273-3-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470144726-5273-1-git-send-email-michael.g.wood@intel.com> References: <1470144726-5273-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 2/5] toaster: checksettings call django's loaddata instead of custom command X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 13:32:19 -0000 Call django's inbuilt loaddata command to load the appropriate fixtures. We also attempt to load a fixture called "custom" and fail silently if we don't have one. This is where initial customisations can be done to load particular settings or data into Toaster (for example layers or default values for variables) Make sure the value for TEMPLATECONF is available to checksettings so that we can have a go a working out which default data to load. Signed-off-by: Michael Wood --- bitbake/bin/toaster | 3 +- .../management/commands/checksettings.py | 55 +++++++++++++++++----- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index e3a0dae..02f87a3 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster @@ -59,7 +59,8 @@ webserverStartAll() echo "Failed migrations, aborting system start" 1>&2 return $retval fi - + # Make sure that checksettings can pick up any value for TEMPLATECONF + export TEMPLATECONF $MANAGE checksettings --traceback || retval=1 if [ $retval -eq 1 ]; then diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py index 8cdc813..fcee8b0 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py @@ -1,10 +1,15 @@ from django.core.management.base import NoArgsCommand, CommandError from django.db import transaction + +from django.core.management import call_command from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException from bldcontrol.models import BuildRequest, BuildEnvironment, BRError -from orm.models import ToasterSetting, Build +from orm.models import ToasterSetting, Build, Layer + import os import traceback +import warnings + def DN(path): if path is None: @@ -94,30 +99,58 @@ class Command(NoArgsCommand): print("\n -- Validation: The build directory must to be set to an absolute path.") is_changed = _update_builddir() - if is_changed: print("\nBuild configuration saved") be.save() return True - if be.needs_import: try: - config_file = os.environ.get('TOASTER_CONF') - print("\nImporting file: %s" % config_file) - from .loadconf import Command as LoadConfigCommand + print("Loading default settings") + call_command("loaddata", "settings") + template_conf = os.environ.get("TEMPLATECONF", "") + + if "poky" in template_conf: + print("Loading poky configuration") + call_command("loaddata", "poky") + else: + print("Loading OE-Core configuration") + call_command("loaddata", "oe-core") + if template_conf: + oe_core_path = os.realpath(template_conf + + "/../") + else: + print("TEMPLATECONF not found. You may have to" + " manually configure layer paths") + oe_core_path = input("Please enter the path of" + " your openembedded-core " + "layer: ") + # Update the layer instances of openemebedded-core + for layer in Layer.objects.filter( + name="openembedded-core"): + layer.local_source_dir = oe_core_path + layer.save() + + # Import the custom fixture if it's present + with warnings.catch_warnings(): + warnings.filterwarnings( + action="ignore", + message="^.*No fixture named.*$") + print("Importing custom settings if present") + call_command("loaddata", "custom") - LoadConfigCommand()._import_layer_config(config_file) # we run lsupdates after config update - print("\nLayer configuration imported. Updating information from the layer sources, please wait.\nYou can re-update any time later by running bitbake/lib/toaster/manage.py lsupdates") - from django.core.management import call_command + print("\nFetching information from the layer index, " + "please wait.\nYou can re-update any time later " + "by running bitbake/lib/toaster/manage.py " + "lsupdates\n") call_command("lsupdates") # we don't look for any other config files return is_changed except Exception as e: - print("Failure while trying to import the toaster config file %s: %s" %\ - (config_file, e)) + print("Failure while trying to setup toaster: %s" + % e) traceback.print_exc() return is_changed -- 2.7.4