Class LoadFileCommand

java.lang.Object
edu.wisc.ssec.mcidasv.jython.Command
edu.wisc.ssec.mcidasv.jython.LoadFileCommand

class LoadFileCommand extends Command
This class is a type of Command that represents a request to use Jython to run a file containing Jython statements. This is conceptually a bit similar to importing a module, but the loading is done behind the scenes and you may specify whatever namespace you like (be careful!).
  • Field Details

    • name

      private String name
      Namespace to use when executing path.
    • path

      private String path
      Path to the Jython file awaiting execution.
  • Constructor Details

    • LoadFileCommand

      public LoadFileCommand(Console console, String name, String path)
      Creates a command that will attempt to execute a Jython file in the namespace given by name.
      Parameters:
      console - Originating console.
      name - Namespace to use when executing path.
      path - Path to a Jython file.
  • Method Details

    • execute

      public void execute(Interpreter interpreter) throws Exception
      Tries to load the file specified by path using moduleName for the __name__ attribute. Note that this command does not currently display any results in the originating Console.

      If moduleName is not __main__, this command is basically the same thing as doing from moduleName import *.

      If moduleName is __main__, then this command will work for if __name__ == '__main__' and will run main functions as expected.

      Specified by:
      execute in class Command
      Parameters:
      interpreter - Interpreter to use to load the specified file.
      Throws:
      Exception - if Jython has a problem with running path.
    • toString

      public String toString()
      Overrides:
      toString in class Object