Cleanup PiscalSshClient ending newlines

This commit is contained in:
2016-05-11 10:30:18 -04:00
parent aca7157663
commit b0c586fab4
4 changed files with 12 additions and 6 deletions
+5 -6
View File
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Common; using System.Data.Common;
using System.IO; using System.IO;
@@ -19,7 +18,7 @@ namespace LeafWeb.Core.Remote
private const string StatusRunning = "running"; private const string StatusRunning = "running";
private const string StatusNotStarted = "not started"; private const string StatusNotStarted = "not started";
Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Logger _logger = LogManager.GetCurrentClassLogger();
public PiscalSshClient(string connectionString) public PiscalSshClient(string connectionString)
{ {
@@ -81,9 +80,9 @@ namespace LeafWeb.Core.Remote
ssh.Disconnect(); ssh.Disconnect();
if (command.ExitStatus != 0) if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Result); throw new PiscalClientException(leafInput.LeafInputId, command.Result.TrimEndNewLine());
_logger.Debug("RunLeafInput result: " + command.Result); _logger.Debug("RunLeafInput result: " + command.Result.TrimEndNewLine());
} }
} }
@@ -115,7 +114,7 @@ namespace LeafWeb.Core.Remote
ssh.Disconnect(); ssh.Disconnect();
if (command.ExitStatus != 0) if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Result); throw new PiscalClientException(leafInput.LeafInputId, command.Result.TrimEndNewLine());
return command.Result return command.Result
.SplitNewLine() .SplitNewLine()
@@ -169,7 +168,7 @@ namespace LeafWeb.Core.Remote
ssh.Disconnect(); ssh.Disconnect();
if (command.ExitStatus != 0) if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Error); throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
} }
} }
} }
+5
View File
@@ -62,6 +62,11 @@ namespace LeafWeb.Core.Utility
return Regex.Replace(path, @".*/([^/]*$)", "$1"); return Regex.Replace(path, @".*/([^/]*$)", "$1");
} }
public static string TrimEndNewLine(this string input)
{
return input.TrimEnd('\r', '\n');
}
public static string Join<T>(this IEnumerable<T> enumerable, string separator) public static string Join<T>(this IEnumerable<T> enumerable, string separator)
{ {
return string.Join(separator, enumerable); return string.Join(separator, enumerable);
+1
View File
@@ -101,6 +101,7 @@ namespace LeafWeb.Web.Controllers
} }
// Callback from Piscal // Callback from Piscal
[ActionLog]
public void NotifyComplete() public void NotifyComplete()
{ {
HangfireStartup.TriggerPiscalProcessQueue(); HangfireStartup.TriggerPiscalProcessQueue();
@@ -38,6 +38,7 @@ namespace LeafWeb.Web.Services.PiscalQueue
} }
} }
// TODO: clear any stalled processes
private void ClearStalled() private void ClearStalled()
{ {
var leafInputs = var leafInputs =