コード例 #1
0
        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();
        }
コード例 #2
0
        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.
        }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: RunOnHost.cs プロジェクト: cliftonm/FiddleDock
        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);
        }
コード例 #5
0
ファイル: Run.cs プロジェクト: cliftonm/FiddleDock
 public override void Execute(string requestData)
 {
     PythonCode pcode = JsonConvert.DeserializeObject <PythonCode>(requestData);
     string     code  = Encoding.ASCII.GetString(Convert.FromBase64String(pcode.Code));
 }