From b101897de2507cf0b2549f32f9cb89ccc98bcbcb Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 8 May 2015 09:40:25 +0000 Subject: scripts/release-build: Add some error checks and warnings The script is a bit tricky to use, otherwise. --- scripts/release-build | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/release-build b/scripts/release-build index 5525e9e9..e74ac593 100755 --- a/scripts/release-build +++ b/scripts/release-build @@ -17,10 +17,12 @@ import cliapp import morphlib + import os import subprocess import sys import time +import warnings class Build(object): @@ -60,6 +62,25 @@ class ReleaseApp(cliapp.Application): 'Baserock version of the systems being built', default='yy.ww') + def log_config(self): + def pretty_warnings(message, category, filename, lineno, + file=None, line=None): + return 'WARNING: %s\n' % (message) + + warnings.formatwarning = pretty_warnings + + def error(self, message): + raise cliapp.AppException(message) + + def check_args(self, args): + if len(args) == 0: + self.error( + "Please pass the name of the release cluster (e.g. " + "clusters/release.morph)") + + if len(args) > 1: + self.error("Too many arguments given.") + def process_args(self, args): '''Process the command line''' self.controllers = {} @@ -76,6 +97,8 @@ class ReleaseApp(cliapp.Application): self.loader = morphlib.morphloader.MorphologyLoader() self.finder = morphlib.morphologyfinder.MorphologyFinder(defs_repo) + self.check_args(args) + cluster_name = args[0] cluster, cluster_path = self.load_morphology(cluster_name) @@ -126,6 +149,10 @@ class ReleaseApp(cliapp.Application): system, _ = self.load_morphology(system_name) if system['arch'] in self.controllers: builds.append(Build(system_name, system['arch'], self)) + else: + warnings.warn( + "Not building '%s': no distbuild controller for %s " + "available." % (system['name'], system['arch'])) return builds def deploy_images(self, cluster, cluster_path): -- cgit v1.2.1