Exemple #1
0
        public static bool testJython(string scriptToExecute, string expectedDataReceived)
        {
            var jythonExecution = new JythonShell();
            var dataReceived    = jythonExecution.executeScript(scriptToExecute);

            return(dataReceived == expectedDataReceived);
        }
        public static Process startJythonShell(DataReceivedEventHandler dataReceivedCallBack)
        {
            var jythonShell = new JythonShell();

            jythonShell.startJythonShell(dataReceivedCallBack);
            return(jythonShell.jythonProcess);
        }
        // if we pass a callback for logging we need to start a python shell
        public static Process executePythonFile(string fileToExecute, DataReceivedEventHandler dataReceivedCallBack)
        {
            var jythonShell = new JythonShell();

            jythonShell.startJythonShell(dataReceivedCallBack, fileToExecute);
            return(jythonShell.jythonProcess);
        }
Exemple #4
0
        public void testJythonScriptExecution()
        {
            Assert.That(JythonInstall.checkJythonInstallation(), "checkJythonInstallation return false");
            Assert.That(JythonShell.testJython("print 2+3", "5"), "testJython failed");
            Assert.That(false == JythonShell.testJython("print 2+3", "4"), "testJython should had failed");

            var scriptToExecute = "print 2+3";
            var expectedDataReceived = "5" + Environment.NewLine;
            var tempPyScript = DI.config.getTempFileInTempDirectory("py");
            Files.WriteFileContent(tempPyScript, scriptToExecute);
            
            var dataReceived = new JythonShell().executePythonFile(tempPyScript, "");
            Assert.That(dataReceived == expectedDataReceived, "data received did no match expectedDataReceived");
            File.Delete(tempPyScript);
        }
Exemple #5
0
        public static void installJython()
        {
            if (false == File.Exists(JythonConfig.zippedJythonRunTime))
            {
                DI.log.error("in installJython, could not find zippedJythonRunTime: {0}", JythonConfig.zippedJythonRunTime);
            }
            else
            {
                DI.log.info("Installing Jython to: {0}", JythonConfig._jythonRuntimeDir);
                new zipUtils().unzipFile(JythonConfig.zippedJythonRunTime, JythonConfig._jythonRuntimeDir);
                if (Directory.Exists(JythonConfig._jythonRuntimeDir))
                {
                    DI.log.info("Jyhton sucessfully installed");
                }
                else
                {
                    DI.log.error("Problem installing/unziping _jythonRuntimeDir: {0}", JythonConfig._jythonRuntimeDir);
                }

                JythonShell.testJython();   // need to run Jython once so that the _Jython_Runtime\cachedir\packages is created and populated
            }
        }
 public static Process startJythonShell(DataReceivedEventHandler dataReceivedCallBack)
 {
     var jythonShell = new JythonShell();
     jythonShell.startJythonShell(dataReceivedCallBack);
     return jythonShell.jythonProcess;            
 }
 // if we pass a callback for logging we need to start a python shell
 public static Process executePythonFile(string fileToExecute, DataReceivedEventHandler dataReceivedCallBack)
 {
     var jythonShell = new JythonShell();
     jythonShell.startJythonShell(dataReceivedCallBack, fileToExecute);
     return jythonShell.jythonProcess;
 }
 public static bool testJython(string scriptToExecute, string expectedDataReceived)
 {
     var jythonExecution = new JythonShell();            
     var dataReceived = jythonExecution.executeScript(scriptToExecute);
     return dataReceived == expectedDataReceived;
 }
 public static void openJythonShellOnCmdExe()
 {
     JythonShell.openJythonShellOnCmdExe();
 }