def test57(): from actuator.namespace import _ComputableValue try: _ = _ComputableValue(object()) assert False, "_ComputableValue should have complained about the value supplied" except NamespaceException, e: assert "unrecognized" in e.message.lower()
def _get_arg_value(self, arg): val = super(_ConfigTask, self)._get_arg_value(arg) if isinstance(val, basestring): #check if we have a variable to resolve cv = _ComputableValue(val) try: var_context = self.get_task_role() except ConfigException, _: mi = self.get_model_instance() if mi is None: raise ConfigException("Can't find a model to get a default var context") var_context = mi.namespace_model_instance if var_context is None: raise ConfigException("Can't find a namespace to use as a var context") val = cv.expand(var_context)
def _make_args(self, task): args = super(ProcessCopyFileProcessor, self)._make_args(task) complex_args = args["complex_args"] if "src" in complex_args: if not os.path.exists(complex_args["src"]): raise ExecutionException("Can't find the file {}".format(complex_args["src"])) content = file(complex_args["src"], "r").read() else: content = complex_args["content"] cv = _ComputableValue(content) result = cv.expand(task.get_task_role(), raise_on_unexpanded=True) complex_args["content"] = result try: del complex_args["src"] except: pass return args