def run_optimizer(self, *args, **kwargs): # load the environment and initialize compiler = load_environment()(self) compiler_args = compiler.args() compiler_args.extend([self.resource_path("r.js"), "-o"]) compiler_args.extend(args) if self.verbosity == 0: kwargs.setdefault("logLevel", "4") compiler_args.extend("{0}={1}".format(key, value) for key, value in kwargs.items()) # Run the compiler in a subprocess. if subprocess.call(compiler_args) != 0: raise OptimizationError("Error while running r.js optimizer.")