From a22e729a3cf7ddab5465b311be602ee36eb095ce Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 6 Nov 2012 21:32:37 +0100 Subject: [PATCH] raise special error on missing manifest Signed-off-by: Nico Schottelius --- cdist/core/manifest.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 5faeccd1..ecc4a490 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -25,6 +25,20 @@ import os import cdist +class NoInitialManifestError(cdist.Error): + """ + Display missing initial manifest + """ + + def __init__(self, manifest_path): + if os.path.islink(manifest_path): + self.message = "%s -> %s" (manifest_path, os.path.realpath(manifest_path)) + else: + self.message = manifest_path + + def __str__(self): + return "Initial manifest missing: %s" % self.message + ''' common: runs only locally, does not need remote @@ -84,6 +98,11 @@ class Manifest(object): env['__manifest'] = self.local.manifest_path env['__cdist_manifest'] = script self.log.info("Running initial manifest " + self.local.manifest_path) + + if not os.path.isfile(self.local.manifest_path): + print("fooooobar") + raise NoInitialManifestError(self.local.manifest_path) + self.local.run_script(script, env=env) def run_type_manifest(self, cdist_object):