30#include <xercesc/parsers/SAXParser.hpp>
39 const std::string& templateStr, FXMenuPane* menu) :
40 myApplicationWindow(applicationWindow),
42 myPythonToolName(
FileHelpers::getFileFromPath(toolPath, true)) {
47 if (templateStr.size() > 0) {
95 const char* pythonEnv = getenv(
"PYTHON");
96 const std::string python = (pythonEnv ==
nullptr) ?
"python" : pythonEnv;
97 const char* sumoHomeEnv = getenv(
"SUMO_HOME");
98 std::string sumoHome =
"";
99 if (sumoHomeEnv !=
nullptr && sumoHomeEnv != std::string(
"")) {
100 sumoHome = std::string(sumoHomeEnv);
102 if (sumoHome.back() ==
'\\') {
105 if (sumoHome.back() !=
'/') {
109 if (sumoHome.front() !=
'"') {
110 sumoHome =
"\"" + sumoHome;
112 if (sumoHome.back() ==
'"') {
116 return python +
" " + sumoHome +
myToolPath +
"\"";
122 std::string arguments;
126 if (!option.second->isDefault()) {
128 if (option.second->isBool()) {
129 if (option.second->getBool()) {
130 arguments += (
"--" + option.first +
" ");
132 arguments += (
"--no-" + option.first +
" ");
135 if (!option.second->isPositional()) {
136 arguments += (
"--" + option.first +
" ");
138 const std::string listSeparator = option.second->getListSeparator();
139 if (listSeparator !=
"") {
142 for (
const std::string& v : st.
getVector()) {
146 arguments += listSeparator;
148 arguments += (
"\"" + v +
"\"");
165 if (value ==
"none") {
178 XERCES_CPP_NAMESPACE::SAXParser parser;
179 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Never);
180 parser.setDisableDefaultEntityResolution(
true);
184 parser.setDocumentHandler(&handler);
185 parser.setErrorHandler(&handler);
188 WRITE_ERROR(
TL(
"Could not load tool configuration '") + file +
"'.");
191 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
203 std::string command =
getCommand() +
" -C \"" + file +
"\" ";
206 command = command +
" &";
209 command =
"start /B \"\" " + command;
@ MID_GNE_OPENPYTHONTOOLDIALOG
call tool
#define WRITE_MESSAGE(msg)
Functions for an easier usage of files and paths.
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 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
static std::string transcode(const XMLCh *const data, int length=-1)
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