OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
PostProcessor.cpp File Reference
#include "PostProcessor.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/format.hpp"
#include "libslic3r_version.h"
#include "I18N.hpp"
#include "libslic3r/Config.hpp"
#include "slic3r/plugin/PluginManager.hpp"
#include "slic3r/plugin/pluginTypes/slicingPipeline/SlicingPipelinePluginCapability.hpp"
#include "slic3r/plugin/PythonInterpreter.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/log/trivial.hpp>
#include <boost/format.hpp>
#include <boost/filesystem.hpp>
#include <boost/nowide/cstdlib.hpp>
#include <boost/nowide/convert.hpp>
#include <boost/nowide/fstream.hpp>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <exception>
#include <iostream>
#include <fstream>
#include "libslic3r/PrintConfig.hpp"
#include <memory>
#include "libslic3r/Print.hpp"
#include "libslic3r/Exception.hpp"
#include <slic3r/plugin/PythonPluginInterface.hpp>
#include <string>
#include <vector>
#include <utility>
#include <boost/algorithm/string/predicate.hpp>
#include <cassert>
#include <cwchar>
#include <stdlib.h>
#include <cstdlib>
#include <slic3r/Utils/BoostProcessCompat.hpp>
Include dependency graph for PostProcessor.cpp:

Go to the source code of this file.

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/

Functions

static int run_script (const std::string &script, const std::string &gcode, std::string &std_err)
void Slic3r::gcode_add_line_number (const std::string &path, const DynamicPrintConfig &config)
static void Slic3r::run_post_process_plugins (const ConfigOptionStrings &capabilities, const ConfigOptionStrings *plugins, const std::string &gcode_path, const std::string &host, const std::string &output_name, const DynamicPrintConfig &config)
bool Slic3r::run_post_process_scripts (std::string &src_path, bool make_copy, const std::string &host, std::string &output_name, const DynamicPrintConfig &config)

Function Documentation

◆ run_script()

int run_script ( const std::string & script,
const std::string & gcode,
std::string & std_err )
static
193{
194 // Try to obtain user's default shell
195 const char* shell = ::getenv("SHELL");
196 if (shell == nullptr) {
197 shell = "/bin/sh";
198 }
199
200 // Quote and escape the gcode path argument
201 std::string command{script};
202 command.append(" '");
203 for (char c : gcode) {
204 if (c == '\'') {
205 command.append("'\\''");
206 } else {
207 command.push_back(c);
208 }
209 }
210 command.push_back('\'');
211
212 BOOST_LOG_TRIVIAL(debug) << boost::format("Executing script, shell: %1%, command: %2%") % shell % command;
213
214 process::ipstream istd_err;
215 process::child child(shell, "-c", command, process::std_err > istd_err);
216
217 std_err.clear();
218 std::string line;
219
220 while (child.running() && std::getline(istd_err, line)) {
221 std_err.append(line);
222 std_err.push_back('\n');
223 }
224
225 child.wait();
226 return child.exit_code();
227}

Referenced by Slic3r::run_post_process_scripts().

Here is the caller graph for this function: