public override void Execute(string requestData) { PythonCode pcode = JsonConvert.DeserializeObject <PythonCode>(requestData); int instanceNumber = pcode.InstanceNumber - 1; var sessionPorts = GetSessionDockerInstancePorts(); instancePort = GetOrCreateContainerPort(ref sessionPorts, instanceNumber); SaveSessionDockerInstancePorts(sessionPorts); // Update with any new ports created in this session. List <string> stdout = GetStdout(); string code = pcode.Code; // This is already base64 encoded. string resp = String.Empty; try { resp = UploadApp(code); VerifyResponse(resp, "ok"); resp = RunApp(); ResetStdout(resp); } catch (Exception ex) { stdout.Add(ex.Message); } // ExitContainer(); }
public override void Execute(string requestData) { PythonCode pcode = JsonConvert.DeserializeObject <PythonCode>(requestData); int instanceNumber = pcode.InstanceNumber - 1; var sessionPorts = GetSessionDockerInstancePorts(); DeleteContainerPort(ref sessionPorts, instanceNumber); SaveSessionDockerInstancePorts(sessionPorts); // Update with any new ports created in this session. }
public Test() { Name = "unnamed test"; BarCodeGray = 128; FileVersion = Settings.FileVersion; CalibrationMean = Program.UserSettings.calibrationMean; CalibrationSD = Program.UserSettings.calibrationSD; Code = new PythonCode(); Paper = new Paper(this); }
public override void Execute(string requestData) { PythonCode pcode = JsonConvert.DeserializeObject <PythonCode>(requestData); string code = Encoding.ASCII.GetString(Convert.FromBase64String(pcode.Code)); string fnTemp = Path.GetTempFileName(); File.WriteAllText(fnTemp, code); var process = Runner.LaunchProcess("python", "-u " + fnTemp, (s) => stdout.Add(s), (err) => stdout.Add(err)); var startTime = DateTime.Now; while (!process.HasExited && (DateTime.Now - startTime).TotalMilliseconds < Constants.MAX_RUN_TIME_MS) { Thread.Sleep(0); } if (!process.HasExited) { process.Kill(); } File.Delete(fnTemp); }
public override void Execute(string requestData) { PythonCode pcode = JsonConvert.DeserializeObject <PythonCode>(requestData); string code = Encoding.ASCII.GetString(Convert.FromBase64String(pcode.Code)); }