public RunnerResult Run() { var scanner = new FileScanner(settings.Recursive); var results = new RunnerResult(); foreach (var startPath in settings.StartPaths) { foreach (var path in scanner.Scan(startPath)) { Assembly assembly; string errorMessage; if ((errorMessage = AssemblyUtils.Load(path, out assembly)) == string.Empty) { IsDebugResult isdebugResult; string debugerror = string.Empty; if ((debugerror = AssemblyUtils.TryIsDebug(assembly, out isdebugResult)) == string.Empty) results.Ok(path, isdebugResult); else results.Fail(errorMessage); } else results.Fail(errorMessage); } } return results; }
public override void Generate(RunnerResult runnerResult) { base.Generate(runnerResult); if (runnerResult.ScanResults != null) { foreach (var r in runnerResult.ScanResults) { if (r.Value.Build == BuildType.Release) { ConsoleEx.Info("{0} (HasDebuggableAttribute :'{1}', IsJITOptimized : '{2}', DebugOutput : '{3}')", r.Key, r.Value.HasDebuggableAttribute, r.Value.IsJITOptimized, r.Value.DebugOutput); } else { ConsoleEx.Warning("{0} (HasDebuggableAttribute :'{1}', IsJITOptimized : '{2}', DebugOutput : '{3}')", r.Key, r.Value.HasDebuggableAttribute, r.Value.IsJITOptimized, r.Value.DebugOutput); } } } //errors foreach (var msg in runnerResult.Errors) { ConsoleEx.Error(msg); } }
private static void HandleResult(string name, RunnerResult result) { switch (result) { case RunnerResult.Success: Console.WriteLine($"Running project {name}" + Environment.NewLine); break; case RunnerResult.AnotherProjectRunning: Console.WriteLine($"Cannot run {name}. Another project is already running." + Environment.NewLine); break; case RunnerResult.ProjectNotRunnable: Console.WriteLine($"{name} is not currently setup and cannot be run." + Environment.NewLine); break; case RunnerResult.UnknownProject: Console.WriteLine($"{name} is not a recognised project." + Environment.NewLine); break; case RunnerResult.ClassNotFound: Console.WriteLine($"Could not get type for: {name}" + Environment.NewLine); break; default: break; } }
public override void Generate(RunnerResult runnerResult) { var serializer = new NewtonsoftJsonSerializer(); var serialize = serializer.Serialize(runnerResult); Console.WriteLine(serialize); }
private void ExecuteTest(NUnitTest test) { // Set Defaults RunnerResult result = RunnerResult.Success; if (test.ToDir == null) { test.ToDir = Project.BaseDirectory; } if (test.OutFile == null) { test.OutFile = "TEST-" + test.Class; } NUnitTestData testData = test.GetTestData(); foreach (FormatterElement element in FormatterElements) { testData.Formatters.Add(element.Data); } if (testData.Fork == true) { result = ExecuteInAppDomain(testData); } else { result = ExecuteInProc(testData); } // Handle return code: // If there is an error/failure and that it should halt, stop // everything otherwise just log a statement. bool errorOccurred = (result == RunnerResult.Errors); bool failureOccurred = (result != RunnerResult.Success); if ((errorOccurred && test.HaltOnError) || (failureOccurred && test.HaltOnFailure)) { // Only thrown if this test should halt as soon as the first // error/failure is detected. In most cases all tests will // be run to get a full list of problems. throw new BuildException("Test " + testData.Class + " Failed", Location); } // Used for reporting the final result from the task. if (errorOccurred) { _errorsPresent = true; } if (failureOccurred) { _failuresPresent = true; } }
public async Task <RunnerResult> StartTraining() { var startInfo = GetDefaultStartInfo(); string scriptSource = _configuration["TrainConfig:TrainScriptPath"]; startInfo.Arguments = $"\"{scriptSource}"; RunnerResult result = await StartJob(startInfo); return(result); }
private static RunnerResult[] GetSubRunners(RunnerResult subRunner, int count) { var subRunners = new RunnerResult[count]; for (int i = 0; i < count; i++) { subRunners[i] = subRunner; } return(subRunners); }
public virtual void Generate(RunnerResult runnerResult) { if (runnerResult == null) return; if (runnerResult.OverralSuccess) { ConsoleEx.Ok("Status {0}, Analyzed {1} assemblies", "OK", runnerResult.TotalFiles); } else { ConsoleEx.Error("Status {0}, Analyzed {1} assemblies (Debug : {2}, Release : {3}, Errors : {4})", "KO", runnerResult.TotalFiles, runnerResult.TotalDebug, runnerResult.TotalRelease, runnerResult.Errors.Count); } }
public async Task <string> StartJob() { TrainJob startedJob = await _trainJobRepo.AddJob(new TrainJob()); RunnerResult result = await _pythonRunner.StartTraining(); if (!result.Failed) { startedJob.IsSuccessful = true; } await _trainJobRepo.Update(startedJob); return(string.IsNullOrEmpty(result.Errors) ? result.Output : result.Errors); }
public virtual void Generate(RunnerResult runnerResult) { if (runnerResult == null) { return; } if (runnerResult.OverralSuccess) { ConsoleEx.Ok("Status {0}, Analyzed {1} assemblies", "OK", runnerResult.TotalFiles); } else { ConsoleEx.Error("Status {0}, Analyzed {1} assemblies (Debug : {2}, Release : {3}, Errors : {4})", "KO", runnerResult.TotalFiles, runnerResult.TotalDebug, runnerResult.TotalRelease, runnerResult.Errors.Count); } }
public async Task <bool> ValidateImage(ImageEntry item) { var start = GetDefaultStartInfo(); string scriptSource = _configuration["UploadConfig:ValidationScriptPath"]; start.Arguments = $"\"{scriptSource}\" \"{item.ImagePath}\""; RunnerResult result = await StartJob(start); if (!string.IsNullOrEmpty(result.Errors) || result.Output.Contains("NOK")) { return(false); } return(true); }
private async void executeButton_Click(object sender, EventArgs e) { cancelButton.Enabled = true; IPXPmx pmx = _args.Host.Connector.Pmx.GetCurrentState(); IPXPmxBuilder builder = _args.Host.Builder.Pmx; XmlDocument doc = new XmlDocument(); doc.Load(pathText.Text); RunnerResult result = await Task.Run(() => { return(Runner.Execute(doc, pmx, builder, _progress)); }); if (result == RunnerResult.Success) { UpdatePmx(pmx); } cancelButton.Enabled = false; }
public override void Generate(RunnerResult runnerResult) { base.Generate(runnerResult); if (runnerResult.ScanResults != null) foreach (var r in runnerResult.ScanResults) { if (r.Value.Build == BuildType.Release) ConsoleEx.Info("{0} (HasDebuggableAttribute :'{1}', IsJITOptimized : '{2}', DebugOutput : '{3}')", r.Key, r.Value.HasDebuggableAttribute, r.Value.IsJITOptimized, r.Value.DebugOutput); else ConsoleEx.Warning("{0} (HasDebuggableAttribute :'{1}', IsJITOptimized : '{2}', DebugOutput : '{3}')", r.Key, r.Value.HasDebuggableAttribute, r.Value.IsJITOptimized, r.Value.DebugOutput); } //errors foreach (var msg in runnerResult.Errors) ConsoleEx.Error(msg); }
public RunnerResult RunDirect(RunnerEnvironment env, List <long> parameter, out long?returnValue) { env.StackFrameDown(Identifier); for (int i = 0; i < Parameter.Count; i++) { env.RegisterVariable(Parameter[i], parameter[i]); } foreach (var vv in Variables.Except(Parameter)) { env.RegisterVariable(vv); } var r = Body.RunDirect(env); while (true) { if (r.ResultType == RunnerResult.RRType.Exit) { returnValue = null; return(r); } else if (r.ResultType == RunnerResult.RRType.Return) { returnValue = env.StackFrameUp(); return(RunnerResult.Normal()); } else if (r.ResultType == RunnerResult.RRType.Normal) { returnValue = env.StackFrameUp(); return(RunnerResult.Normal()); } else if (r.ResultType == RunnerResult.RRType.Jump) { int iskip = Body.List.IndexOf(env.JumpTarget); if (iskip < 0) { throw new InternalCodeRunException($"Label '{env.JumpTarget.Identifier}' not found in {env.CurrentFrame.Name}"); } env.JumpTarget = null; r = Body.RunDirect(env, iskip); } } }
private JsonResult HandleResult(string name, RunnerResult result) { JsonResult jsonResult; switch (result) { case RunnerResult.Success: jsonResult = new JsonResult($"Running project {name}"); jsonResult.StatusCode = StatusCodes.Status200OK; break; case RunnerResult.AnotherProjectRunning: jsonResult = new JsonResult($"Cannot run {name}. Another project is already running."); jsonResult.StatusCode = StatusCodes.Status202Accepted; break; case RunnerResult.ProjectNotRunnable: jsonResult = new JsonResult($"{name} is not currently setup and cannot be run."); jsonResult.StatusCode = StatusCodes.Status409Conflict; break; case RunnerResult.UnknownProject: jsonResult = new JsonResult($"{name} is not a recognised project."); jsonResult.StatusCode = StatusCodes.Status404NotFound; break; case RunnerResult.ClassNotFound: jsonResult = new JsonResult($"Could not get type for: {name}"); jsonResult.StatusCode = StatusCodes.Status500InternalServerError; break; default: jsonResult = new JsonResult($"Runner returned unrecognised result for project {name}"); jsonResult.StatusCode = StatusCodes.Status500InternalServerError; break; } return(jsonResult); }
protected override IGrader CreateGrader(string submissionSource, string studentId, string artifactPath, RunnerResult runnerResult) => new TrxGrader(new TrxGraderTask(submissionSource, studentId, System.IO.Path.Combine(artifactPath, this.TrxFileName)), logger);
public TestRunnerFactoryData(string testName, TestPackage package, RunnerResult result) : base(package, result) { SetName($"{{m}}({testName}"); }
/// <summary> /// Runs a Suite extracted from a TestCase subclass. /// </summary> public void Run(string logPrefix, bool verbose) { CreateFormatters(_nunittest, logPrefix, verbose); _result = new TestResultExtra(); _result.AddListener(this); long startTime = System.DateTime.Now.Ticks; // Handle start OnStartTestSuite(); _suite.Run(_result); // finished test long endTime = System.DateTime.Now.Ticks; long runTime = (endTime-startTime) / 10000; _result.RunTime = runTime; // Handle completion OnEndTestSuite(); if (_result.WasSuccessful == false) { if (_result.ErrorCount != 0) { _resultCode = RunnerResult.Errors; } else if (_result.FailureCount !=0) { _resultCode = RunnerResult.Failures; } } }
private void ThreadProc() { bool good = false; string stdout, stderr; int? exitCode; using (var process = new Process()) { process.StartInfo = _processStartInfo; process.EnableRaisingEvents = true; process.ErrorDataReceived += OnErrorDataReceived; process.OutputDataReceived += OnOutputDataReceived; try { process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); if (_stdin != null) { process.StandardInput.Write(_stdin); } process.StandardInput.Close();//^Z // Should really be able to configure the timeout! MaxValue // is probably safest in the absence of that. if (process.WaitForExit(Int32.MaxValue)) { good = true; } else { process.Kill(); } } catch (System.Exception ex) { _stderrBuilder.Clear(); _stderrBuilder.Append(ex.ToString()); } if (good) { stdout = _stdoutBuilder.ToString(); stderr = _stderrBuilder.ToString(); exitCode = process.ExitCode; } else { stdout = null; stderr = null; exitCode = null; } } if (_callback != null) { var result = new RunnerResult(_jobId, _processStartInfo.FileName, _processStartInfo.Arguments, stdout, stderr, exitCode); Action <RunnerResult> callback = _callback; // https://stackoverflow.com/questions/58237847/how-to-resolve-vs2019-warning-to-use-joinabletaskfactory-switchtomainthreadasyn ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); callback(result); }); } }
protected override IGrader CreateGrader(string submissionSource, string studentId, string artifactPath, RunnerResult runnerResult) => new ConsoleMessagesGrader(new ConsoleMessagesGraderTask(submissionSource, studentId, runnerResult.ConsoleOutput, this.ValidationCode), logger);
public void ExecuteTask(IDuplicityTask task) { Dictionary <string, string> options = new Dictionary <string, string>(); //Set the log level to be that of the GUI options["log-level"] = Duplicati.Library.Logging.Log.LogLevel.ToString(); string destination = task.GetConfiguration(options); string results = ""; string parsedMessage = ""; m_isAborted = false; try { //TODO: Its a bit dirty to set the options after creating the instance using (Interface i = new Interface(destination, options)) { lock (m_lock) { m_stopReason = System.Windows.Forms.CloseReason.None; m_currentBackupControlInterface = i; } SetupControlInterface(); i.OperationProgress += new OperationProgressEvent(Duplicati_OperationProgress); switch (task.TaskType) { case DuplicityTaskType.FullBackup: case DuplicityTaskType.IncrementalBackup: { //Activate auto-cleanup options["auto-cleanup"] = ""; options["force"] = ""; if (task.Schedule.Task.KeepFull > 0) { m_extraOperations++; } if (!string.IsNullOrEmpty(task.Schedule.Task.KeepTime)) { m_extraOperations++; } Library.Utility.TempFolder tf = null; try { if (ProgressEvent != null) { ProgressEvent(DuplicatiOperation.Backup, RunnerState.Started, task.Schedule.Name, "", 0, -1); } if (task.Task.IncludeSetup) { //Make a copy of the current database tf = new Duplicati.Library.Utility.TempFolder(); string filename = System.IO.Path.Combine(tf, System.IO.Path.GetFileName(Program.DatabasePath)); System.IO.File.Copy(Program.DatabasePath, filename, true); using (System.Data.IDbConnection con = (System.Data.IDbConnection)Activator.CreateInstance(SQLiteLoader.SQLiteConnectionType)) { con.ConnectionString = "Data Source=" + filename; //Open the database, handle any encryption issues automatically Program.OpenDatabase(con); using (System.Data.IDbCommand cmd = con.CreateCommand()) { //Remove all log data to minimize the size of the database cmd.CommandText = "DELETE FROM CommandQueue;"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM Log;"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM LogBlob;"; cmd.ExecuteNonQuery(); //Free up unused space cmd.CommandText = "VACUUM;"; cmd.ExecuteNonQuery(); } } options["signature-control-files"] = filename; } options["full-if-sourcefolder-changed"] = ""; List <KeyValuePair <bool, string> > filters = new List <KeyValuePair <bool, string> >(); string[] sourceFolders = DynamicSetupHelper.GetSourceFolders(task.Task, new ApplicationSettings(task.Task.DataParent), filters); if (options.ContainsKey("filter")) { filters.AddRange(Library.Utility.FilenameFilter.DecodeFilter(options["filter"])); } options["filter"] = Library.Utility.FilenameFilter.EncodeAsFilter(filters); //At this point we register the backup as being in progress ((FullOrIncrementalTask)task).WriteBackupInProgress(Strings.DuplicatiRunner.ShutdownWhileBackupInprogress); results = i.Backup(sourceFolders); } finally { if (tf != null) { tf.Dispose(); } if (ProgressEvent != null) { ProgressEvent(DuplicatiOperation.Backup, RunnerState.Stopped, task.Schedule.Name, "", 100, -1); } } break; } case DuplicityTaskType.ListBackups: List <string> res = new List <string>(); foreach (ManifestEntry be in i.GetBackupSets()) { res.Add(be.Time.ToString()); foreach (ManifestEntry bei in be.Incrementals) { res.Add(bei.Time.ToString()); } } (task as ListBackupsTask).Backups = res.ToArray(); break; case DuplicityTaskType.ListBackupEntries: (task as ListBackupEntriesTask).Backups = i.GetBackupSets(); break; case DuplicityTaskType.ListFiles: (task as ListFilesTask).Files = i.ListCurrentFiles(); break; case DuplicityTaskType.ListSourceFolders: (task as ListSourceFoldersTask).Files = new List <string>(i.ListSourceFolders() ?? new string[0]); break; case DuplicityTaskType.ListActualFiles: (task as ListActualFilesTask).Files = i.ListActualSignatureFiles(); break; case DuplicityTaskType.RemoveAllButNFull: results = i.DeleteAllButNFull(); break; case DuplicityTaskType.RemoveOlderThan: results = i.DeleteOlderThan(); break; case DuplicityTaskType.Restore: options["file-to-restore"] = ((RestoreTask)task).SourceFiles; if (options.ContainsKey("filter")) { options.Remove("filter"); } try { if (ProgressEvent != null) { ProgressEvent(DuplicatiOperation.Restore, RunnerState.Started, task.Schedule.Name, "", 0, -1); } results = i.Restore(task.LocalPath.Split(System.IO.Path.PathSeparator)); } finally { if (ProgressEvent != null) { ProgressEvent(DuplicatiOperation.Restore, RunnerState.Stopped, task.Schedule.Name, "", 100, -1); } } break; case DuplicityTaskType.RestoreSetup: i.RestoreControlFiles(task.LocalPath); break; default: return; } } } catch (Exception ex) { while (ex is System.Reflection.TargetInvocationException && ex.InnerException != null) { ex = ex.InnerException; } if (ex is System.Threading.ThreadAbortException) { m_isAborted = true; System.Threading.Thread.ResetAbort(); } else if (ex is Library.Main.LiveControl.ExecutionStoppedException) { m_isAborted = true; } if (m_isAborted && m_stopReason != System.Windows.Forms.CloseReason.None) { //If the user has stopped the backup for some reason, write a nicer message switch (m_stopReason) { case System.Windows.Forms.CloseReason.ApplicationExitCall: parsedMessage = Strings.DuplicatiRunner.ApplicationExitLogMesssage; break; case System.Windows.Forms.CloseReason.TaskManagerClosing: parsedMessage = Strings.DuplicatiRunner.TaskManagerCloseMessage; break; case System.Windows.Forms.CloseReason.UserClosing: parsedMessage = Strings.DuplicatiRunner.UserClosingMessage; break; case System.Windows.Forms.CloseReason.WindowsShutDown: parsedMessage = Strings.DuplicatiRunner.WindowsShutdownMessage; break; default: parsedMessage = string.Format(Strings.DuplicatiRunner.OtherAbortMessage, m_stopReason); break; } if (task.Schedule != null) { //If the application is going down, the backup should resume on next launch switch (m_stopReason) { case System.Windows.Forms.CloseReason.ApplicationExitCall: case System.Windows.Forms.CloseReason.TaskManagerClosing: case System.Windows.Forms.CloseReason.WindowsShutDown: task.Schedule.ScheduledRunFailed(); break; } } } else { parsedMessage = string.Format(Strings.DuplicatiRunner.ErrorMessage, ex.Message); } results = "Error: " + ex.ToString(); //Don't localize while (ex.InnerException != null) { ex = ex.InnerException; results += Environment.NewLine + "InnerError: " + ex.ToString(); //Don't localize } } finally { lock (m_lock) m_currentBackupControlInterface = null; } try { if (!m_isAborted && (task.TaskType == DuplicityTaskType.FullBackup || task.TaskType == DuplicityTaskType.IncrementalBackup)) { if (task.Schedule.Task.KeepFull > 0) { m_lastPGProgress = 100; m_lastPGmessage = Strings.DuplicatiRunner.CleaningUpMessage; m_lastPGSubmessage = ""; m_lastPGSubprogress = -1; ReinvokeLastProgressEvent(); m_extraOperations--; RemoveAllButNFullTask tmpTask = new RemoveAllButNFullTask(task.Schedule, (int)task.Schedule.Task.KeepFull); ExecuteTask(tmpTask); results += Environment.NewLine + Strings.DuplicatiRunner.CleanupLogdataHeader + Environment.NewLine + tmpTask.Result; } if (!string.IsNullOrEmpty(task.Schedule.Task.KeepTime)) { m_lastPGProgress = 100; m_lastPGmessage = Strings.DuplicatiRunner.CleaningUpMessage; m_lastPGSubmessage = ""; m_lastPGSubprogress = -1; ReinvokeLastProgressEvent(); m_extraOperations--; RemoveOlderThanTask tmpTask = new RemoveOlderThanTask(task.Schedule, task.Schedule.Task.KeepTime); ExecuteTask(tmpTask); results += Environment.NewLine + Strings.DuplicatiRunner.CleanupLogdataHeader + Environment.NewLine + tmpTask.Result; } if (task.Schedule.Task.KeepFull > 0 || !string.IsNullOrEmpty(task.Schedule.Task.KeepTime)) { ReinvokeLastProgressEvent(); } if (ProgressEvent != null) { ProgressEvent(DuplicatiOperation.Backup, RunnerState.Stopped, task.Schedule.Name, "", 100, -1); } } } catch (Exception ex) { results += Environment.NewLine + string.Format(Strings.DuplicatiRunner.CleanupError, ex.Message); } task.IsAborted = m_isAborted; task.Result = results; task.RaiseTaskCompleted(results, parsedMessage); if (ResultEvent != null && task is FullBackupTask || task is IncrementalBackupTask) { Log[] logs = Program.DataConnection.GetObjects <Log>("TaskID = ? AND SubAction LIKE ? ORDER BY EndTime DESC", task.Task.ID, "Primary"); if (logs != null && logs.Length > 0) { Datamodel.Log l = logs[0]; RunnerResult r = RunnerResult.Error; if (l.ParsedStatus == DuplicatiOutputParser.ErrorStatus) { r = RunnerResult.Error; } else if (l.ParsedStatus == DuplicatiOutputParser.OKStatus || l.ParsedStatus == DuplicatiOutputParser.NoChangedFiles) { r = RunnerResult.OK; } else if (l.ParsedStatus == DuplicatiOutputParser.PartialStatus) { r = RunnerResult.Partial; } else if (l.ParsedStatus == DuplicatiOutputParser.WarningStatus) { r = RunnerResult.Warning; } ResultEvent(r, parsedMessage, results); } } if (task.Schedule != null && !m_isAborted) { task.Schedule.ScheduledRunCompleted(); //Register as completed if not aborted } }