def run(self, env): if "OCTAVE_ENGINE" not in env: logging.error("OCTAVE_ENGINE not defined") raise TaskError("OCTAVE_ENGINE not defined") engine = env["OCTAVE_ENGINE"] input_strs = [] # If input argument is a variable, push into Octave's memory. # Otherwise, pass the input argument directly in the command. for arg in self.input: key = utils.get_substitution_key(arg, env) if key: engine.push(key, env[key]) input_strs.append(key) logging.info("Pushing variable " + key + " to Octave with value " + str(env[key])) elif isinstance(arg, str) and arg in env: logging.info("Pushing variable " + arg + " to Octave with value " + str(env[arg])) engine.push(arg, env[arg]) input_strs.append(arg) elif isinstance(arg, str): input_strs.append(utils.substitute(arg, env)) else: input_strs.append(str(arg)) # Build the command command = "" if len(self.output) > 0: command += "[" command += ",".join(self.output) command += "] = " command += self.name command += "(" command += ",".join(input_strs) command += ");" logging.info("Evaluating within Octave: " + command) engine.eval(command) for arg in self.output: env[arg] = engine.pull(arg) logging.info("Pulled variable " + arg + " from Octave with value " + str(env[arg]))
def run(self, env): if "OCTAVE_ENGINE" not in env: logging.error("OCTAVE_ENGINE not defined") raise TaskError("OCTAVE_ENGINE not defined") engine = env["OCTAVE_ENGINE"] env_key = utils.get_substitution_key(self.value, env) if env_key: engine.push(self.key, env[env_key]) logging.info("Pushing variable " + self.key + " to Octave with value " + str(env[env_key])) elif isinstance(self.value, str) and self.value in env: engine.push(self.key, env[self.value]) logging.info("Pushing variable " + self.key + " to Octave with value " + str(env[self.value])) elif isinstance(self.value, str): value = utils.substitute(self.value, env) engine.push(self.key, value) logging.info("Pushing variable " + self.key + " to Octave with value " + str(value)) else: engine.push(self.key, self.value) logging.info("Pushing variable " + self.key + " to Octave with value " + str(self.value))