Skip to content

Commit

Permalink
Handling exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed May 15, 2016
1 parent 011abc8 commit f72ed35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions PythonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,29 @@ static string GetPathFromMicrosoftRegister()
{
var regex = new Regex(@"""([^""]*)\\([^""\\]+(?:\.[^"".\\]+))""");
var pythonKey = Registry.ClassesRoot.OpenSubKey(@"Python.File\shell\open\command");
var python = pythonKey.GetValue(null).ToString();
var match = regex.Match(python);
if (pythonKey != null)
{
var python = pythonKey.GetValue(null).ToString();
var match = regex.Match(python);

if (!match.Success) return null;
if (!match.Success) return null;

var directory = match.Groups[1].Value;
var fullPath = Path.Combine(directory, "pythonw");
var process = new RunProcess(fullPath, "--version");
var directory = match.Groups[1].Value;
var fullPath = Path.Combine(directory, "pythonw");
var process = new RunProcess(fullPath, "--version");

process.Run();
process.Run();

if (!process.Success)
return null;
if (!process.Success)
return null;

Logger.Debug(string.Format("Python found by Microsoft Register: {0}", fullPath));
Logger.Debug(string.Format("Python found by Microsoft Register: {0}", fullPath));

return fullPath;
return fullPath;
}

Logger.Info("There's no Python path from Micforost Register");
return null;
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion WakaTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void OnConnection(object application, ext_ConnectMode connectMode, object
}
else
MessageBox.Show(
@"Please install Python (https://www.python.org/downloads/) and restart Visual Studio to enable the WakaTime plugin.",
@"Please install Python (https://www.python.org/downloads/) and restart SQL Server Management Studio to enable the WakaTime plugin.",
@"WakaTime", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

Expand Down

0 comments on commit f72ed35

Please sign in to comment.