yt handler basic theory seems to work
This commit is contained in:
parent
5fc0359e04
commit
57be4c1f47
@ -29,6 +29,7 @@ namespace Schedulable.Show
|
||||
{
|
||||
public string cmd { get; set; }
|
||||
public string args { get; set; }
|
||||
public TimeSpan timeout { get; set; }
|
||||
public TimeSpan leadTime { get; set; }
|
||||
}
|
||||
public class CommandLineCheck
|
||||
|
@ -37,6 +37,7 @@ namespace ShowHandlers
|
||||
~YoutubeHandler()
|
||||
{
|
||||
//Telefranz.Instance.removeHandler<silver_messages.global.report>(agentReports);
|
||||
//Telefranz.Instance.removeHandler<silver_messages.directorial.check_complete>(checkReports);
|
||||
}
|
||||
protected void PreShow(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
@ -54,6 +55,7 @@ namespace ShowHandlers
|
||||
preShow_GetAgents(evt, commandLeadNeeded + TimeSpan.FromMinutes(10));
|
||||
preShow_RunChecks(evt, commandLeadNeeded);
|
||||
preShow_RunCommands(evt);
|
||||
Console.WriteLine("pre show seems to be set.");
|
||||
}
|
||||
protected void preShow_GetAgents(iCalHoopJumping.CalendarOccurrence evt, TimeSpan leadNeeded)
|
||||
{
|
||||
@ -78,7 +80,6 @@ namespace ShowHandlers
|
||||
}
|
||||
protected void preShow_RunChecks(iCalHoopJumping.CalendarOccurrence evt, TimeSpan leadNeeded)
|
||||
{
|
||||
Console.WriteLine("pre show: run checks:");
|
||||
checksProgress.Clear();
|
||||
var argsList = new List<string>() { JsonConvert.SerializeObject(evt) };
|
||||
//Telefranz.Instance.addHandler()
|
||||
@ -86,6 +87,7 @@ namespace ShowHandlers
|
||||
{
|
||||
checksProgress.Add(c.cmd, false);
|
||||
}
|
||||
Console.WriteLine($"pre show: run checks: {string.Join(", ", config.PreShow.Checks.Select(c => c.cmd))}");
|
||||
Action issueChecks = () => {
|
||||
foreach (var checkCmd in checksProgress.Where(cp => cp.Value == false).Select(kvp => kvp.Key))
|
||||
{
|
||||
@ -114,7 +116,26 @@ namespace ShowHandlers
|
||||
}
|
||||
protected void preShow_RunCommands(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
Console.WriteLine("pre show: run commands");
|
||||
Console.WriteLine($"pre show: run commands: {string.Join(", ", config.PreShow.Commands.Select(c => c.cmd))}");
|
||||
foreach(var cmd in config.PreShow.Commands.OrderByDescending(cmd => cmd.leadTime))
|
||||
{
|
||||
if(DateTime.Now < evt.OccurrenceStart - cmd.leadTime)
|
||||
{
|
||||
var waitTime = evt.OccurrenceStart - cmd.leadTime - DateTime.Now;
|
||||
Console.WriteLine($"waiting {waitTime} before executing {cmd.cmd}");
|
||||
Task.WaitAll(Task.Delay(waitTime));
|
||||
}
|
||||
var argsList = new List<string>() { JsonConvert.SerializeObject(evt) }.Append(cmd.args).ToList();
|
||||
|
||||
Console.WriteLine($"telefranzing execution: {cmd.cmd} with args {string.Join(' ', argsList)}");
|
||||
// Telefranz.Instance.ProduceMessage(new silver_messages.directorial.execute_command()
|
||||
// {
|
||||
// command = cmd.cmd,
|
||||
// args = argsList,
|
||||
// timeout = (int)cmd.timeout.TotalMilliseconds //TODO: update when franz gets updated
|
||||
// });
|
||||
}
|
||||
Console.WriteLine("seems all pre-show commands have been issued, but to be fair I wasn't listening for output.");
|
||||
}
|
||||
protected void agentReports(silver_messages.global.report r)
|
||||
{
|
||||
@ -141,7 +162,21 @@ namespace ShowHandlers
|
||||
}
|
||||
protected void PostShow(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
Console.WriteLine("can't do this bit without understanding when a show ends, sooo.");
|
||||
|
||||
Console.WriteLine($"post show: run commands: {string.Join(", ", config.PostShow.Commands.Select(c => c.cmd))}");
|
||||
foreach(var cmd in config.PostShow.Commands)
|
||||
{
|
||||
var argsList = new List<string>() { JsonConvert.SerializeObject(evt) }.Append(cmd.args).ToList();
|
||||
|
||||
Console.WriteLine($"telefranzing execution: {cmd.cmd} with args {string.Join(' ', argsList)}");
|
||||
// Telefranz.Instance.ProduceMessage(new silver_messages.directorial.execute_command()
|
||||
// {
|
||||
// command = cmd.cmd,
|
||||
// args = argsList,
|
||||
// timeout = (int)cmd.timeout.TotalMilliseconds //TODO: update when franz gets updated
|
||||
// });
|
||||
}
|
||||
Console.WriteLine("seems all post-show commands have been issued, but to be fair I wasn't listening for output.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user