edu.wisc.ssec.mcidasv.jython
Class LoadFileCommand

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.jython.Command
      extended by 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 Summary
private  String name
          Namespace to use when executing path.
private  String path
          Path to the Jython file awaiting execution.
 
Fields inherited from class edu.wisc.ssec.mcidasv.jython.Command
console
 
Constructor Summary
LoadFileCommand(Console console, String name, String path)
          Creates a command that will attempt to execute a Jython file in the namespace given by name.
 
Method Summary
 void execute(Interpreter interpreter)
          Tries to load the file specified by path using moduleName for the __name__ attribute.
 String toString()
           
 
Methods inherited from class edu.wisc.ssec.mcidasv.jython.Command
getInputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private String name
Namespace to use when executing path.


path

private String path
Path to the Jython file awaiting execution.

Constructor Detail

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 Detail

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