コード例 #1
0
ファイル: Setup.cs プロジェクト: schifflee/InteligentRPA
        private static int CheckPythonVer()
        {
            try
            {
                string   result       = RunCommand(null, "python", "--version");
                string[] versionSplit = result.Replace("Python", "").Trim().Split('.');

                var filepath = CommandLinePathResolver.TryGetFullPathForCommand("python.exe");
                var path     = System.IO.Path.GetDirectoryName(filepath);
                SetPythonPath(path);

                return(Convert.ToInt32(versionSplit[0] + versionSplit[1]));
            }
            catch
            {
                try
                {
                    string   result       = RunCommand(null, "python3", "--version");
                    string[] versionSplit = result.Replace("Python", "").Trim().Split('.');

                    var filepath = CommandLinePathResolver.TryGetFullPathForCommand("python3.exe");
                    var path     = System.IO.Path.GetDirectoryName(filepath);
                    SetPythonPath(path);

                    //pythonCommand = "python3";
                    pipCommand = "pip3";
                    return(Convert.ToInt32(versionSplit[0] + versionSplit[1]));
                }
                catch (Exception)
                {
                    return(0);
                }
            }
        }
コード例 #2
0
ファイル: Setup.cs プロジェクト: vantk85/openrpa
        private static int CheckPythonVer()
        {
            try
            {
                string result = RunCommand(null, "python", "--version");
                string[] versionSplit = result.Replace("Python", "").Trim().Split('.');

                var PYTHON_PATH = PythonUtil.Setup.GetEnv("PYTHON_PATH");
                if (string.IsNullOrEmpty(PYTHON_PATH))
                {
                    var filepath = CommandLinePathResolver.TryGetFullPathForCommand("python");
                    var path = System.IO.Path.GetDirectoryName(filepath);
                    SetPythonPath(path, true);
                }

                return Convert.ToInt32(versionSplit[0] + versionSplit[1]);
            }
            catch
            {
                try
                {
                    string result = RunCommand(null, "python3", "--version");
                    string[] versionSplit = result.Replace("Python", "").Trim().Split('.');

                    var PYTHON_PATH = PythonUtil.Setup.GetEnv("PYTHON_PATH");
                    if (string.IsNullOrEmpty(PYTHON_PATH))
                    {
                        var filepath = CommandLinePathResolver.TryGetFullPathForCommand("python3");
                        var path = System.IO.Path.GetDirectoryName(filepath);
                        SetPythonPath(path, true);
                    }

                    //pythonCommand = "python3";
                    //pipCommand = "pip3";
                    return Convert.ToInt32(versionSplit[0] + versionSplit[1]);
                }
                catch (Exception)
                {
                    return 0;
                }
            }
        }
コード例 #3
0
ファイル: Setup.cs プロジェクト: vantk85/openrpa
 public static string GetExePath(string exec)
 {
     var path = "";
     var PYTHON_PATH = GetEnv("PYTHON_PATH");
     var PYTHON_HOME = GetEnv("PYTHON_HOME");
     if (!exec.EndsWith(".exe") && !exec.EndsWith(".bat")) exec = exec + ".exe";
     if (!string.IsNullOrEmpty(PluginConfig.python_exe_path) && System.IO.File.Exists(System.IO.Path.Combine(PluginConfig.python_exe_path, exec)))
     {
         path = PluginConfig.python_exe_path;
     }
     if (!string.IsNullOrEmpty(PluginConfig.python_exe_path) && System.IO.File.Exists(System.IO.Path.Combine(PluginConfig.python_exe_path, "Scripts", exec)))
     {
         path = System.IO.Path.Combine(PluginConfig.python_exe_path, "Scripts");
     }
     else if (!string.IsNullOrEmpty(PYTHON_PATH) && System.IO.File.Exists(System.IO.Path.Combine(PYTHON_PATH, exec)))
     {
         path = PYTHON_PATH;
     }
     else if (!string.IsNullOrEmpty(PYTHON_PATH) && System.IO.File.Exists(System.IO.Path.Combine(PYTHON_PATH, "Scripts", exec)))
     {
         path = System.IO.Path.Combine(PYTHON_PATH, "Scripts");
     }
     else if (!string.IsNullOrEmpty(PYTHON_HOME) && System.IO.File.Exists(System.IO.Path.Combine(PYTHON_HOME, exec)))
     {
         path = PYTHON_HOME;
     }
     else if (!string.IsNullOrEmpty(PYTHON_HOME) && System.IO.File.Exists(System.IO.Path.Combine(PYTHON_HOME, "Scripts", exec)))
     {
         path = System.IO.Path.Combine(PYTHON_HOME, "Scripts");
     }
     else
     {
         var temppath = CommandLinePathResolver.TryGetFullPathForCommand(exec);
         if (!string.IsNullOrEmpty(temppath)) path = System.IO.Path.GetDirectoryName(temppath);
     }
     return path;
 }