Display results from Piscal processing

Error handling for Piscal processing
This commit is contained in:
2016-03-07 11:47:55 -05:00
parent c80d048c39
commit 05b2bfefb1
11 changed files with 191 additions and 58 deletions
+1
View File
@@ -8,5 +8,6 @@ namespace LeafWeb.Core.Remote
PiscalStatus GetLeafInputFileStatus(PiscalLeafInputFile file);
IEnumerable<PiscalLeafOutputFile> RetrieveLeafOutput(PiscalLeafInputFile file);
void CleanupLeafProcess(PiscalLeafInputFile file);
string GetErrorMessage(PiscalLeafInputFile file);
}
}
+15 -2
View File
@@ -16,6 +16,7 @@ namespace LeafWeb.Core.Remote
private const string StatusSuccess = "success";
private const string StatusRunning = "running";
private const string StatusNotStarted = "not started";
private const string StatusError = "error";
public PiscalSshClient(string connectionString)
@@ -62,7 +63,7 @@ namespace LeafWeb.Core.Remote
ssh.Disconnect();
if (command.ExitStatus != 0)
throw new PiscalClientException(command.Error);
throw new PiscalClientException(command.Result);
Console.Write(command.Result);
}
@@ -78,6 +79,8 @@ namespace LeafWeb.Core.Remote
return PiscalStatus.Running;
case StatusSuccess:
return PiscalStatus.Success;
case StatusNotStarted:
return PiscalStatus.NotStarted;
default:
return PiscalStatus.Error;
}
@@ -94,7 +97,7 @@ namespace LeafWeb.Core.Remote
ssh.Disconnect();
if (command.ExitStatus != 0)
throw new PiscalClientException(command.Error);
throw new PiscalClientException(command.Result);
return command.Result
.SplitNewLine()
@@ -137,6 +140,16 @@ namespace LeafWeb.Core.Remote
}
}
public string GetErrorMessage(PiscalLeafInputFile file)
{
var status = GetLeafInputStatusRaw(file);
if (status[0] != StatusError)
return string.Empty;
var errorLines = status.Skip(1).ToArray();
return errorLines.Join(Environment.NewLine);
}
public void CleanupLeafProcess(PiscalLeafInputFile file)
{
var status = GetLeafInputStatusRaw(file);
+1
View File
@@ -4,6 +4,7 @@ namespace LeafWeb.Core.Remote
{
Running,
Success,
NotStarted,
Error
}
}
+6
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
@@ -50,5 +51,10 @@ namespace LeafWeb.Core.Utility
{
return Regex.Replace(path, @".*/([^/]*$)", "$1");
}
public static string Join<T>(this IEnumerable<T> enumerable, string separator)
{
return string.Join(separator, enumerable);
}
}
}