29#include <xercesc/parsers/SAXParser.hpp>
38 const std::string& templateStr, FXMenuPane* menu) :
41 myPythonToolName(
FileHelpers::getFileFromPath(toolPath, true)) {
46 if (templateStr.size() > 0) {
100 const char* pythonEnv = getenv(
"PYTHON");
101 const std::string python = (pythonEnv ==
nullptr) ?
"python" : pythonEnv;
102 const char* sumoHomeEnv = getenv(
"SUMO_HOME");
103 std::string sumoHome =
"";
104 if (sumoHomeEnv !=
nullptr && sumoHomeEnv != std::string(
"")) {
105 sumoHome = std::string(sumoHomeEnv);
107 if (sumoHome.back() ==
'\\') {
110 if (sumoHome.back() !=
'/') {
114 if (sumoHome.front() !=
'"') {
115 sumoHome =
"\"" + sumoHome;
117 if (sumoHome.back() ==
'"') {
121 return python +
" " + sumoHome +
myToolPath +
"\"";
127 std::string arguments;
131 if (!option.second->isDefault()) {
133 if (option.second->isBool()) {
134 arguments += (
"--" + option.first +
" ");
136 if (!option.second->isPositional()) {
137 arguments += (
"--" + option.first +
" ");
139 const std::string listSeparator = option.second->getListSeparator();
140 if (listSeparator !=
"") {
143 for (
const std::string& v : st.
getVector()) {
147 arguments += listSeparator;
149 arguments += (
"\"" + v +
"\"");
166 if (value ==
"none") {
179 XERCES_CPP_NAMESPACE::SAXParser parser;
180 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Never);
181 parser.setDisableDefaultEntityResolution(
true);
185 parser.setDocumentHandler(&handler);
186 parser.setErrorHandler(&handler);
189 WRITE_ERROR(
TL(
"Could not load tool configuration '") + file +
"'.");
192 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
208 if (!option.second->isDefault()) {
209 if (option.second->isBool()) {
210 command += (
"--" + option.first +
" ");
218 command = command +
" &";
221 command =
"start /B \"\" " + command;
@ MID_GNE_OPENPYTHONTOOLDIALOG
call tool
#define WRITE_MESSAGE(msg)
Functions for an easier usage of files and paths.
The main window of Netedit.
static FXMenuCommand * buildFXMenuCommandShortcut(FXComposite *p, const std::string &text, const std::string &shortcut, const std::string &info, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
A storage for options typed value containers)
std::string getValueString(const std::string &name) const
Returns the string-value of the named option (all options)
void resetWritable()
Resets all options to be writeable.
A SAX-Handler for loading options.
bool errorOccurred() const
Returns the information whether an error occurred.
std::vector< std::string > getVector()
return vector of strings
static std::string escapeShell(const std::string &orig)
Escape special characters with backslash.
static std::string transcode(const XMLCh *const data)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage
static unsigned long runHiddenCommand(const std::string &cmd)
run a shell command without popping up any windows (particuarly on win32)
static void parseTemplate(OptionsCont &options, const std::string &templateString)
run parser