org.pyant.tasks
Class PythonBaseTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.pyant.tasks.PythonBaseTask
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
PythonInteractiveBaseTask, PythonRunTask

public class PythonBaseTask
extends org.apache.tools.ant.Task

Author:
Ron Smith Base class for Python Ant tasks. Tasks inheriting from this task support the following attributes:

Field Summary
protected  boolean failonerror
           
protected  int optimize
           
protected  String python
           
protected  org.apache.tools.ant.types.Path pythonpath
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
PythonBaseTask()
           
 
Method Summary
protected  void addCommandlineArgs(org.apache.tools.ant.types.Commandline cmdline)
           
protected  org.apache.tools.ant.types.Commandline createCommandline()
           
protected  org.apache.tools.ant.taskdefs.Execute createExecute(org.apache.tools.ant.Project project, org.apache.tools.ant.types.Commandline cmdline, File workingDirectory)
          Create the Execute task to be run.
protected  org.apache.tools.ant.taskdefs.ExecuteStreamHandler createStreamHandler()
           
protected  void execExecuteTask(String failMsg, org.apache.tools.ant.taskdefs.Execute runner)
          Execute the given Execute task.
protected  void executeScript(org.apache.tools.ant.Project project, File workingDirectory, String failMsg)
          Execute the python script.
protected  void failureOcurred(String msg)
           
protected  String fixFilePath(String path)
          Convert file paths to be forward slashes for Python.
protected  org.apache.tools.ant.types.Commandline getCommandline()
           
 String getPython()
           
protected  void prepCommandline()
           
 void setFailonerror(boolean failonerror)
           
 void setOptimize(int optimize)
           
protected  void setOptimizeArgument(org.apache.tools.ant.types.Commandline cmdline)
           
 void setPython(String python)
           
 void setPythonpath(org.apache.tools.ant.types.Path pythonpath)
          Set the PYTHONPATH as a string
protected  void setPythonPathInExecute(org.apache.tools.ant.taskdefs.Execute runner)
          Set the PYTHONPATH as an environment variable into the given Execute task
 void setPythonpathref(String pathref)
          Set the PYTHONPATH as an Ant path reference.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pythonpath

protected org.apache.tools.ant.types.Path pythonpath

python

protected String python

failonerror

protected boolean failonerror

optimize

protected int optimize
Constructor Detail

PythonBaseTask

public PythonBaseTask()
Method Detail

setPythonPathInExecute

protected void setPythonPathInExecute(org.apache.tools.ant.taskdefs.Execute runner)
Set the PYTHONPATH as an environment variable into the given Execute task


setPythonpath

public void setPythonpath(org.apache.tools.ant.types.Path pythonpath)
Set the PYTHONPATH as a string

Parameters:
pythonpath - The pythonpath to set.

setPythonpathref

public void setPythonpathref(String pathref)
Set the PYTHONPATH as an Ant path reference.

Parameters:
pathref -

getPython

public String getPython()

setPython

public void setPython(String python)

fixFilePath

protected String fixFilePath(String path)
Convert file paths to be forward slashes for Python. Windows: Why oh why would you choose the universal escape character as your file delimeter?


setFailonerror

public void setFailonerror(boolean failonerror)

executeScript

protected void executeScript(org.apache.tools.ant.Project project,
                             File workingDirectory,
                             String failMsg)
Execute the python script. This function will construct the command line, set up the environment, and execute the Python script. The particulars are expected to be set up by derived classes.

Parameters:
project - - Ant project
workingDirectory - - Working directory to execute from
failMsg - - Message to be reported upon execution failure

execExecuteTask

protected void execExecuteTask(String failMsg,
                               org.apache.tools.ant.taskdefs.Execute runner)
Execute the given Execute task.

Parameters:
failMsg -
runner -

createExecute

protected org.apache.tools.ant.taskdefs.Execute createExecute(org.apache.tools.ant.Project project,
                                                              org.apache.tools.ant.types.Commandline cmdline,
                                                              File workingDirectory)
Create the Execute task to be run.

Parameters:
project - - Ant project
cmdline - - Commandline to be executed
workingDirectory - - Working directory to execute from
Returns:
Execute task

createStreamHandler

protected org.apache.tools.ant.taskdefs.ExecuteStreamHandler createStreamHandler()

getCommandline

protected org.apache.tools.ant.types.Commandline getCommandline()

createCommandline

protected org.apache.tools.ant.types.Commandline createCommandline()

prepCommandline

protected void prepCommandline()

addCommandlineArgs

protected void addCommandlineArgs(org.apache.tools.ant.types.Commandline cmdline)

failureOcurred

protected void failureOcurred(String msg)

setOptimize

public void setOptimize(int optimize)

setOptimizeArgument

protected void setOptimizeArgument(org.apache.tools.ant.types.Commandline cmdline)


Copyright © 2010. All Rights Reserved.