lordgamez commented on code in PR #1721:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1721#discussion_r1559538680


##########
extensions/python/PythonDependencyInstaller.cpp:
##########
@@ -0,0 +1,166 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "PythonDependencyInstaller.h"
+
+#include "PythonScriptException.h"
+#include "PythonInterpreter.h"
+#include "PyException.h"
+#include "types/Types.h"
+
+namespace org::apache::nifi::minifi::extensions::python {
+
+namespace {
+
+std::string getPythonBinary(const std::shared_ptr<Configure> &configuration) {
+#if WIN32
+  std::string python_binary_ = "python";
+#else
+  std::string python_binary_ = "python3";
+#endif
+  if (auto binary = 
configuration->get(minifi::Configuration::nifi_python_env_setup_binary)) {
+    python_binary_ = *binary;
+  }
+  return python_binary_;

Review Comment:
   Good catch, updated in 33e8770038e823678763c9bef60cc656c07ba16b



##########
extensions/python/PythonDependencyInstaller.cpp:
##########
@@ -0,0 +1,166 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "PythonDependencyInstaller.h"
+
+#include "PythonScriptException.h"
+#include "PythonInterpreter.h"
+#include "PyException.h"
+#include "types/Types.h"
+
+namespace org::apache::nifi::minifi::extensions::python {
+
+namespace {
+
+std::string getPythonBinary(const std::shared_ptr<Configure> &configuration) {
+#if WIN32
+  std::string python_binary_ = "python";
+#else
+  std::string python_binary_ = "python3";
+#endif
+  if (auto binary = 
configuration->get(minifi::Configuration::nifi_python_env_setup_binary)) {
+    python_binary_ = *binary;
+  }
+  return python_binary_;
+}
+
+// On Windows when calling a system command using std::system, the whole 
command needs to be encapsulated in additional quotes,
+// due to the std::system passing the command to 'cmd.exe /C' which needs the 
additional quotes to handle the command as a single argument
+std::string encapsulateCommandInQuotesIfNeeded(const std::string& command) {
+#if WIN32
+    return "\"" + command + "\"";
+#else
+    return command;
+#endif
+}
+
+}  // namespace
+
+PythonDependencyInstaller::PythonDependencyInstaller(const 
std::shared_ptr<Configure> &configuration) {
+  python_binary_ = getPythonBinary(configuration);
+  std::string automatic_install_str;
+  install_python_packages_automatically_ =
+    
configuration->get(Configuration::nifi_python_install_packages_automatically, 
automatic_install_str) && 
utils::string::toBool(automatic_install_str).value_or(false);

Review Comment:
   Good idea, updated in 33e8770038e823678763c9bef60cc656c07ba16b



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to