src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java
protected int runCommand() throws Exception {
        File prebat = new File(_dir, "PRE.bat");
        if (prebat.isFile()) {
            try {
                Runtime.getRuntime().exec("cmd.exe " + prebat.getName());
            } catch (Exception e) {
                System.err.println("could not launch PRE.bat:\n" + e);
            }
        }

        File presh = new File(_dir, "PRE.sh");
        if (presh.isFile()) {
            try {
                Runtime.getRuntime().exec("/bin/sh " + presh.getName());
            } catch (Exception e) {
                System.err.println("could not launch PRE.sh:\n" + e);
            }
        }

        File prepy = new File(_dir, "PRE.py");
        if (prepy.isFile()) {
            if (ParserUtils.getASCIIFileContent(prepy).contains("print(")) {
                try {
                    Runtime.getRuntime().exec("python3 " + prepy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch PRE.py:\n" + e);
                }
            } else if (ParserUtils.getASCIIFileContent(prepy).contains("print ")) {
                try {
                    Runtime.getRuntime().exec("python2 " + prepy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch PRE.py:\n" + e);
                }
            } else {
                try {
                    Runtime.getRuntime().exec("python " + prepy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch PRE.py:\n" + e);
                }
            }
        }

        //System.err.println("runCommand " + Arrays.asList(_dir.listFiles()));
        _process = new org.funz.util.Process(buildCommand(), _dir, _plugin.getVariables()) {
            @Override
            public void over(int i) {
                try {
                    executionOver(i);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        };
        int ret = _process.runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
        _reason = _process.getFailReason();

        if (ret == 0) {
            File postbat = new File(_dir, "POST.bat");
            if (postbat.isFile()) {
                try {
                    Runtime.getRuntime().exec("cmd.exe " + postbat.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.bat:\n" + e);
                }
            }

            File postsh = new File(_dir, "POST.sh");
            if (postsh.isFile()) {
                try {
                    Runtime.getRuntime().exec("/bin/sh " + postsh.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.sh:\n" + e);
                }
            }

            File postpy = new File(_dir, "POST.py");
            if (postpy.isFile()) {
                if (ParserUtils.getASCIIFileContent(postpy).contains("print(")) {
                try {
                    Runtime.getRuntime().exec("python3 " + postpy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.py:\n" + e);
                }
            } else if (ParserUtils.getASCIIFileContent(postpy).contains("print ")) {
                try {
                    Runtime.getRuntime().exec("python2 " + postpy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.py:\n" + e);
                }
            } else {
                try {
                    Runtime.getRuntime().exec("python " + postpy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.py:\n" + e);
                }
            }
            }
        }
        if (tunnel!=null) tunnel.stop();
        return ret;
    }
/**
     * Called by execute() when the code is launched by a script. The first file
     * of the project is used as the (only) argument of the script. To be
     * overloaded for special cases, for instance when the script asks for
     * several arguments, or some options.
     *
     * @return int return status of the process
     */
Called by execute() when the code is launched by a script. The first file
of the project is used as the (only) argument of the script. To be
overloaded for special cases, for instance when the script asks for
several arguments, or some options.

@return int return status of the process
Called by execute () when the code is launched by a script . The first file of the project is used as the ( only ) argument of the script . To be overloaded for special cases for instance when the script asks for several arguments or some options . @return int return status of the process
protected int runCommand() throws Exception {
        File prebat = new File(_dir, "PRE.bat");
        if (prebat.isFile()) {
            try {
                Runtime.getRuntime().exec("cmd.exe " + prebat.getName());
            } catch (Exception e) {
                System.err.println("could not launch PRE.bat:\n" + e);
            }
        }
        File presh = new File(_dir, "PRE.sh");
        if (presh.isFile()) {
            try {
                Runtime.getRuntime().exec("/bin/sh " + presh.getName());
            } catch (Exception e) {
                System.err.println("could not launch PRE.sh:\n" + e);
            }
        }
        File prepy = new File(_dir, "PRE.py");
        if (prepy.isFile()) {
            if (ParserUtils.getASCIIFileContent(prepy).contains("print(")) {
                try {
                    Runtime.getRuntime().exec("python3 " + prepy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch PRE.py:\n" + e);
                }
            } else if (ParserUtils.getASCIIFileContent(prepy).contains("print ")) {
                try {
                    Runtime.getRuntime().exec("python2 " + prepy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch PRE.py:\n" + e);
                }
            } else {
                try {
                    Runtime.getRuntime().exec("python " + prepy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch PRE.py:\n" + e);
                }
            }
        }
        _process = new org.funz.util.Process(buildCommand(), _dir, _plugin.getVariables()) {
            @Override
            public void over(int i) {
                try {
                    executionOver(i);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        };
        int ret = _process.runCommand(new FileOutputStream(_dir + File.separator + outName), new FileOutputStream(_dir + File.separator + errName), new FileOutputStream(_dir + File.separator + logName));
        _reason = _process.getFailReason();
        if (ret == 0) {
            File postbat = new File(_dir, "POST.bat");
            if (postbat.isFile()) {
                try {
                    Runtime.getRuntime().exec("cmd.exe " + postbat.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.bat:\n" + e);
                }
            }
            File postsh = new File(_dir, "POST.sh");
            if (postsh.isFile()) {
                try {
                    Runtime.getRuntime().exec("/bin/sh " + postsh.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.sh:\n" + e);
                }
            }
            File postpy = new File(_dir, "POST.py");
            if (postpy.isFile()) {
                if (ParserUtils.getASCIIFileContent(postpy).contains("print(")) {
                try {
                    Runtime.getRuntime().exec("python3 " + postpy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.py:\n" + e);
                }
            } else if (ParserUtils.getASCIIFileContent(postpy).contains("print ")) {
                try {
                    Runtime.getRuntime().exec("python2 " + postpy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.py:\n" + e);
                }
            } else {
                try {
                    Runtime.getRuntime().exec("python " + postpy.getName());
                } catch (Exception e) {
                    System.err.println("could not launch POST.py:\n" + e);
                }
            }
            }
        }
        if (tunnel!=null) tunnel.stop();
        return ret;
    }
protected int runCommand ( ) throws Exception { File prebat = new File ( _dir , "PRE.bat" ) ; if ( prebat . isFile ( ) ) { try { Runtime . getRuntime ( ) . exec ( "cmd.exe " + prebat . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch PRE.bat:\n" + e ) ; } } File presh = new File ( _dir , "PRE.sh" ) ; if ( presh . isFile ( ) ) { try { Runtime . getRuntime ( ) . exec ( "/bin/sh " + presh . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch PRE.sh:\n" + e ) ; } } File prepy = new File ( _dir , "PRE.py" ) ; if ( prepy . isFile ( ) ) { if ( ParserUtils . getASCIIFileContent ( prepy ) . contains ( "print(" ) ) { try { Runtime . getRuntime ( ) . exec ( "python3 " + prepy . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch PRE.py:\n" + e ) ; } } else if ( ParserUtils . getASCIIFileContent ( prepy ) . contains ( "print " ) ) { try { Runtime . getRuntime ( ) . exec ( "python2 " + prepy . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch PRE.py:\n" + e ) ; } } else { try { Runtime . getRuntime ( ) . exec ( "python " + prepy . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch PRE.py:\n" + e ) ; } } } _process = new org . funz . util . Process ( buildCommand ( ) , _dir , _plugin . getVariables ( ) ) { @ Override public void over ( int i ) { try { executionOver ( i ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } } ; int ret = _process . runCommand ( new FileOutputStream ( _dir + File . separator + outName ) , new FileOutputStream ( _dir + File . separator + errName ) , new FileOutputStream ( _dir + File . separator + logName ) ) ; _reason = _process . getFailReason ( ) ; if ( ret == 0 ) { File postbat = new File ( _dir , "POST.bat" ) ; if ( postbat . isFile ( ) ) { try { Runtime . getRuntime ( ) . exec ( "cmd.exe " + postbat . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch POST.bat:\n" + e ) ; } } File postsh = new File ( _dir , "POST.sh" ) ; if ( postsh . isFile ( ) ) { try { Runtime . getRuntime ( ) . exec ( "/bin/sh " + postsh . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch POST.sh:\n" + e ) ; } } File postpy = new File ( _dir , "POST.py" ) ; if ( postpy . isFile ( ) ) { if ( ParserUtils . getASCIIFileContent ( postpy ) . contains ( "print(" ) ) { try { Runtime . getRuntime ( ) . exec ( "python3 " + postpy . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch POST.py:\n" + e ) ; } } else if ( ParserUtils . getASCIIFileContent ( postpy ) . contains ( "print " ) ) { try { Runtime . getRuntime ( ) . exec ( "python2 " + postpy . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch POST.py:\n" + e ) ; } } else { try { Runtime . getRuntime ( ) . exec ( "python " + postpy . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch POST.py:\n" + e ) ; } } } } if ( tunnel != null ) tunnel . stop ( ) ; return ret ; }
Called by execute() when the code is launched by a script.
Called by execute () when the code is launched by a script .
//System.err.println("runCommand " + Arrays.asList(_dir.listFiles()));