| 3118 | } |
| 3119 | |
| 3120 | void Application::processCmdLineFiles() |
| 3121 | { |
| 3122 | const std::list<std::string> files = getCmdLineFiles(); |
| 3123 | const std::list<std::string> processed = processFiles(files); |
| 3124 | |
| 3125 | if (files.empty()) { |
| 3126 | if (mConfig["RunMode"] == "Exit") |
| 3127 | mConfig["RunMode"] = "Cmd"; |
| 3128 | } |
| 3129 | else if (processed.empty() && files.size() == 1 && mConfig["RunMode"] == "Cmd") { |
| 3130 | // In case we are in console mode and the argument is not a file but Python code |
| 3131 | // then execute it. This is to behave like the standard Python executable. |
| 3132 | const Base::FileInfo file(files.front()); |
| 3133 | if (!file.exists()) { |
| 3134 | Base::Interpreter().runString(files.front().c_str()); |
| 3135 | mConfig["RunMode"] = "Exit"; |
| 3136 | } |
| 3137 | } |
| 3138 | |
| 3139 | const std::map<std::string, std::string>& cfg = Application::Config(); |
| 3140 | const auto it = cfg.find("SaveFile"); |
| 3141 | if (it != cfg.end()) { |
| 3142 | std::string output = it->second; |
| 3143 | output = Base::Tools::escapeEncodeFilename(output); |
| 3144 | |
| 3145 | const Base::FileInfo fi(output); |
| 3146 | try { |
| 3147 | const std::vector<std::string> mods = GetApplication().getExportModules(fi.extension()); |
| 3148 | if (!mods.empty()) { |
| 3149 | Base::Interpreter().loadModule(mods.front().c_str()); |
| 3150 | Base::Interpreter().runStringArg("import %s",mods.front().c_str()); |
| 3151 | Base::Interpreter().runStringArg("%s.export(App.ActiveDocument.Objects, '%s')" |
| 3152 | ,mods.front().c_str(),output.c_str()); |
| 3153 | } |
| 3154 | else { |
| 3155 | Base::Console().warning("File format not supported: %s \n", output.c_str()); |
| 3156 | } |
| 3157 | } |
| 3158 | catch (const Base::Exception& e) { |
| 3159 | Base::Console().error("Exception while saving to file: %s [%s]\n", output.c_str(), e.what()); |
| 3160 | } |
| 3161 | catch (...) { |
| 3162 | Base::Console().error("Unknown exception while saving to file: %s \n", output.c_str()); |
| 3163 | } |
| 3164 | } |
| 3165 | } |
| 3166 | |
| 3167 | void Application::runApplication() |
| 3168 | { |
nothing calls this directly
no test coverage detected