mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-05 08:40:01 -06:00
added "Executor" node to run any process against a file
This commit is contained in:
Binary file not shown.
@@ -30,6 +30,22 @@
|
||||
"IncludePatterns-Help": "Optional, if set only files matching these patterns will be counted to see if the folder is empty. Any of these patterns can match."
|
||||
}
|
||||
},
|
||||
"Executor": {
|
||||
"Description": "Execute the following process against the file.\nOutput 1: The process returned the success exit code\nOutput 2: The process return a non-successful exit code.",
|
||||
"Fields": {
|
||||
"FileName": "File Name",
|
||||
"FileName-Help": "The name of the file to execute",
|
||||
"Arguments": "Arguments",
|
||||
"Arguments-Help": "The arguments to be passed to the process to execute",
|
||||
"WorkingDirectory": "Working Directory",
|
||||
"WorkingDirectory-Help": "The directory where the process will be executed from",
|
||||
"SuccessCode": "Success Code",
|
||||
"SuccessCode-Help": "The exit code of the process indicating the process was successful. Usually this should be 0.",
|
||||
"Timeout": "Timeout",
|
||||
"Timeout-Help": "How long the process can run for before being terminated. Use 0 for no timeout.",
|
||||
"Timeout-Suffix": "seconds"
|
||||
}
|
||||
},
|
||||
"FileExtension": {
|
||||
"Description": "Checks if the file has one of the configured extensions.\n\nOutput 1: Matches\nOutput 2: Does not match",
|
||||
"Fields": {
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace BasicNodes.Tests
|
||||
[TestInitialize]
|
||||
public void TestStarting()
|
||||
{
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
Args.Logger = new TestLogger();
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace BasicNodes.Tests
|
||||
[TestInitialize]
|
||||
public void TestStarting()
|
||||
{
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
Args.Logger = new TestLogger();
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace BasicNodes.Tests
|
||||
[TestInitialize]
|
||||
public void TestStarting()
|
||||
{
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
Args.Logger = new TestLogger();
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());
|
||||
|
||||
}
|
||||
|
||||
@@ -59,8 +58,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv");
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -77,8 +75,7 @@ return 0";
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv");
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -96,8 +93,7 @@ return 0";
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv");
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -115,8 +111,7 @@ return 0";
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv");
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"\.mkv$";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.mkv", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
@@ -25,7 +25,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"\.mkv$";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi");
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi", new TestLogger());
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.avi", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
@@ -37,7 +37,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"[-$";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi");
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi", new TestLogger());
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.avi", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
@@ -48,7 +48,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"\-trailer";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile-TRAILER.avi");
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile-TRAILER.avi", new TestLogger());
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.avi", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BasicNodes.Tests
|
||||
new KeyValuePair<string, string>("Seinfeld", "Batman")
|
||||
};
|
||||
node.UnitTest = true;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld.mkv");
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld.mkv", new TestLogger());
|
||||
|
||||
var result = node.Execute(args);
|
||||
Assert.AreEqual(1, result);
|
||||
@@ -34,7 +34,7 @@ namespace BasicNodes.Tests
|
||||
new KeyValuePair<string, string>(@"0([1-9]+x[\d]+)", "$1"),
|
||||
};
|
||||
node.UnitTest = true;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld S03E06.mkv");
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld S03E06.mkv", new TestLogger());
|
||||
|
||||
var result = node.Execute(args);
|
||||
Assert.AreEqual(1, result);
|
||||
|
||||
@@ -11,9 +11,8 @@ namespace BasicNodes.Tests
|
||||
[TestMethod]
|
||||
public void Renamer_Extension()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var logger = new TestLogger();
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -36,9 +35,8 @@ namespace BasicNodes.Tests
|
||||
[TestMethod]
|
||||
public void Renamer_Extension_DoubleDot()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var logger = new TestLogger();
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -62,9 +60,8 @@ namespace BasicNodes.Tests
|
||||
[TestMethod]
|
||||
public void Renamer_Empty_SquareBrackets()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var logger = new TestLogger();
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -87,9 +84,8 @@ namespace BasicNodes.Tests
|
||||
[TestMethod]
|
||||
public void Renamer_Empty_RoundBrackets()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var logger = new TestLogger();
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -111,9 +107,8 @@ namespace BasicNodes.Tests
|
||||
[TestMethod]
|
||||
public void Renamer_Empty_SquareBrackets_Extension()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var logger = new TestLogger();
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -137,9 +132,8 @@ namespace BasicNodes.Tests
|
||||
[TestMethod]
|
||||
public void Renamer_Colon()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv");
|
||||
var logger = new TestLogger();
|
||||
args.Logger = logger;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Batman Unlimited: Mech vs Mutants" },
|
||||
|
||||
70
BasicNodes/Tools/Executor.cs
Normal file
70
BasicNodes/Tools/Executor.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
namespace FileFlows.BasicNodes.File
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
|
||||
public class Executor : Node
|
||||
{
|
||||
public override int Inputs => 1;
|
||||
public override int Outputs => 2;
|
||||
public override FlowElementType Type => FlowElementType.Process;
|
||||
public override string Icon => "fas fa-terminal";
|
||||
|
||||
[Required]
|
||||
[File(1)]
|
||||
public string FileName { get; set; }
|
||||
|
||||
[Required]
|
||||
[TextVariable(2)]
|
||||
public string Arguments { get; set; }
|
||||
|
||||
[Folder(3)]
|
||||
public string WorkingDirectory { get; set; }
|
||||
|
||||
[Required]
|
||||
[NumberInt(4)]
|
||||
public int SuccessCode { get; set; }
|
||||
|
||||
[NumberInt(5)]
|
||||
public int Timeout { get; set; }
|
||||
|
||||
private NodeParameters args;
|
||||
|
||||
public override async Task Cancel()
|
||||
{
|
||||
args?.Process?.Cancel();
|
||||
}
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
this.args = args;
|
||||
string pArgs = args.ReplaceVariables(Arguments ?? string.Empty);
|
||||
var task = args.Process.ExecuteShellCommand(new ExecuteArgs
|
||||
{
|
||||
Command = FileName,
|
||||
Arguments = pArgs,
|
||||
Timeout = Timeout,
|
||||
WorkingDirectory = WorkingDirectory
|
||||
});
|
||||
|
||||
task.Wait();
|
||||
|
||||
if(task.Result.Completed == false)
|
||||
{
|
||||
args.Logger?.ELog("Process failed to complete");
|
||||
return -1;
|
||||
}
|
||||
bool success = task.Result.ExitCode == this.SuccessCode;
|
||||
if (success)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
args.Logger?.ILog("Unsuccesful exit code returned: " + task.Result.ExitCode);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,8 +12,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_Ghostbusters()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 1984.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 1984.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -32,8 +31,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_Ghostbusters2()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 2.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 2.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -52,8 +50,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_WithDots()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.2.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.2.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -72,8 +69,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_WithYear()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.1989.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.1989.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -92,8 +88,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_Folder_WithYear()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = true;
|
||||
@@ -112,8 +107,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_VariablesSet()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = true;
|
||||
@@ -129,8 +123,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_NoMatchNoVariables()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -145,8 +138,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_ComplexFile()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -165,8 +157,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_WonderWoman()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv");
|
||||
args.Logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv", new TestLogger());
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
|
||||
Binary file not shown.
@@ -1,17 +1,17 @@
|
||||
[
|
||||
{
|
||||
"Name": "BasicNodes",
|
||||
"Version": "0.0.1.23",
|
||||
"Version": "0.0.1.24",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true"
|
||||
},
|
||||
{
|
||||
"Name": "MetaNodes",
|
||||
"Version": "0.0.1.23",
|
||||
"Version": "0.0.1.24",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/MetaNodes.zip?raw=true"
|
||||
},
|
||||
{
|
||||
"Name": "VideoNodes",
|
||||
"Version": "0.0.1.23",
|
||||
"Version": "0.0.1.24",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user