WakaTime.PythonManager.TryGetPathFromFixedPath C# (CSharp) Method

TryGetPathFromFixedPath() static private method

static private TryGetPathFromFixedPath ( ) : string
return string
        static string TryGetPathFromFixedPath()
        {
            string[] locations = {
                "pythonw",
                "python",

            // Windows
                GetMainDrive () + "\\Python34\\python.exe",

            // Etc
                "\\Python37\\pythonw",
                "\\Python36\\pythonw",
                "\\Python35\\pythonw",
                "\\Python34\\pythonw",
                "\\Python33\\pythonw",
                "\\Python32\\pythonw",
                "\\Python31\\pythonw",
                "\\Python30\\pythonw",
                "\\Python27\\pythonw",
                "\\Python26\\pythonw",
                "\\python37\\pythonw",
                "\\python36\\pythonw",
                "\\python35\\pythonw",
                "\\python34\\pythonw",
                "\\python33\\pythonw",
                "\\python32\\pythonw",
                "\\python31\\pythonw",
                "\\python30\\pythonw",
                "\\python27\\pythonw",
                "\\python26\\pythonw",
                "\\Python37\\python",
                "\\Python36\\python",
                "\\Python35\\python",
                "\\Python34\\python",
                "\\Python33\\python",
                "\\Python32\\python",
                "\\Python31\\python",
                "\\Python30\\python",
                "\\Python27\\python",
                "\\Python26\\python",
                "\\python37\\python",
                "\\python36\\python",
                "\\python35\\python",
                "\\python34\\python",
                "\\python33\\python",
                "\\python32\\python",
                "\\python31\\python",
                "\\python30\\python",
                "\\python27\\python",
                "\\python26\\python",
            };

            foreach (var location in locations) {
                try {
                    ProcessStartInfo info = new ProcessStartInfo (location, "--version");
                    Process process = new Process ();

                    info.UseShellExecute = false;
                    info.CreateNoWindow = true;

                    process.StartInfo = info;

                    if (!process.Start ()) {
                        continue;
                    }
                } catch (Exception ex) {
                    ex.ToString ();
                    continue;
                }

                PythonBinaryLocation = location;
                return location;
            }

            return null;
        }