From 6fd766d2b071f301ace520dacda89713dd9a91d9 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 14 May 2015 10:06:57 +0000 Subject: generate-manifest-csv: Catch NoRemote error when cloning lorries repo If there is no $trove-id/local-config/lorries repository, and similarly if there is no baserock/local-config/lorries repository on the Trove defined by 'trove-host', the generate-manifest-csv command will fail with a NoRemote error from trying to clone a non-existent repository. This commit fixes this and instead outputs a warning if either of the repositories cannot be found. Change-Id: I8edd8484e45d8fc91021a9be34966c13d2beb705 --- morphlib/plugins/system_manifests_plugin.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/morphlib/plugins/system_manifests_plugin.py b/morphlib/plugins/system_manifests_plugin.py index 1aea8341..cc26e5ca 100644 --- a/morphlib/plugins/system_manifests_plugin.py +++ b/morphlib/plugins/system_manifests_plugin.py @@ -243,21 +243,32 @@ def get_upstream_address(chunk_url, lorries, status): return 'UNKNOWN' def get_lorry_repos(tempdir, lrc, status, trove_id, trove_host): - baserock_lorry_repo = 'baserock:local-config/lorries' - lorrydir = os.path.join(tempdir, 'baserock-lorries') - baserock_lorrydir = checkout_repo(lrc, baserock_lorry_repo, lorrydir) - lorries = load_lorries(lorrydir) + lorries = [] + try: + baserock_lorry_repo = 'baserock:local-config/lorries' + lorrydir = os.path.join(tempdir, 'baserock-lorries') + baserock_lorrydir = checkout_repo(lrc, baserock_lorry_repo, lorrydir) + lorries.extend(load_lorries(lorrydir)) + except morphlib.localrepocache.NoRemote as e: + status(msg="WARNING: Could not find lorries from git.baserock.org, " + "expected to find them on %(trove)s at %(reponame)s", + trove=trove_host, reponame = e.reponame) if trove_id: - trove_lorry_repo = ('http://%s/git/%s/local-config/lorries' % - (trove_host, trove_id)) - lorrydir = os.path.join(tempdir, '%s-lorries' % trove_id) - trove_lorrydir = checkout_repo(lrc, trove_lorry_repo, lorrydir) + try: + trove_lorry_repo = ('http://%s/git/%s/local-config/lorries' % + (trove_host, trove_id)) + lorrydir = os.path.join(tempdir, '%s-lorries' % trove_id) + trove_lorrydir = checkout_repo(lrc, trove_lorry_repo, lorrydir) + lorries.extend(load_lorries(lorrydir)) + except morphlib.localrepocache.NoRemote as e: + status(msg="WARNING: Could not find lorries repo on %(trove)s " + "at %(reponame)s", + trove=trove_host, reponame=e.reponame) else: status(msg="WARNING: Not looking in %(trove)s's local-config/lorries " "repo as trove-id was not configured.", trove=trove_host) - lorries.extend(load_lorries(lorrydir)) return lorries -- cgit v1.2.1