mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-16 21:15:33 -04:00
New: Many UI Updates and Performance Tweaks
This commit is contained in:
@@ -25,6 +25,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override string Name => "Custom Script";
|
||||
|
||||
public override string Link => "https://github.com/Radarr/Radarr/wiki/Custom-Post-Processing-Scripts";
|
||||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
@@ -99,8 +101,6 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override string Name => "Custom Script";
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
@@ -110,17 +110,37 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
failures.Add(new NzbDroneValidationFailure("Path", "File does not exist"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
environmentVariables.Add("Sonarr_EventType", "Test");
|
||||
|
||||
var processOutput = ExecuteScript(environmentVariables);
|
||||
|
||||
if (processOutput.ExitCode != 0)
|
||||
{
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, $"Script exited with code: {processOutput.ExitCode}"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex);
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message));
|
||||
}
|
||||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
|
||||
private void ExecuteScript(StringDictionary environmentVariables)
|
||||
private ProcessOutput ExecuteScript(StringDictionary environmentVariables)
|
||||
{
|
||||
_logger.Debug("Executing external script: {0}", Settings.Path);
|
||||
|
||||
var process = _processProvider.StartAndCapture(Settings.Path, Settings.Arguments, environmentVariables);
|
||||
var processOutput = _processProvider.StartAndCapture(Settings.Path, Settings.Arguments, environmentVariables);
|
||||
|
||||
_logger.Debug("Executed external script: {0} - Status: {1}", Settings.Path, process.ExitCode);
|
||||
_logger.Debug("Script Output: \r\n{0}", string.Join("\r\n", process.Lines));
|
||||
_logger.Debug("Executed external script: {0} - Status: {1}", Settings.Path, processOutput.ExitCode);
|
||||
_logger.Debug("Script Output: \r\n{0}", string.Join("\r\n", processOutput.Lines));
|
||||
|
||||
return processOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user