onExecutionDone(jobs, successFlag) added to QScript.
-- This function is called when the Qscript ends, so scripts can overload this function if they want to run some code after all of the jobs have completed
This commit is contained in:
parent
feeab6075f
commit
a9ba945595
|
|
@ -95,7 +95,8 @@ class QCommandLine extends CommandLineProgram with Logging {
|
|||
def execute = {
|
||||
qGraph.settings = settings
|
||||
|
||||
for (script <- pluginManager.createAllTypes()) {
|
||||
val allQScripts = pluginManager.createAllTypes();
|
||||
for (script <- allQScripts) {
|
||||
logger.info("Scripting " + pluginManager.getName(script.getClass.asSubclass(classOf[QScript])))
|
||||
loadArgumentsIntoObject(script)
|
||||
try {
|
||||
|
|
@ -108,14 +109,19 @@ class QCommandLine extends CommandLineProgram with Logging {
|
|||
logger.info("Added " + script.functions.size + " functions")
|
||||
}
|
||||
|
||||
// Execute the job graph
|
||||
qGraph.run()
|
||||
|
||||
// walk over each script, calling onExecutionDone
|
||||
for (script <- allQScripts) {
|
||||
script.onExecutionDone(script.functions, qGraph.success)
|
||||
}
|
||||
|
||||
if (!qGraph.success) {
|
||||
logger.info("Done with errors")
|
||||
qGraph.logFailed()
|
||||
1
|
||||
} else {
|
||||
logger.info("Done")
|
||||
0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,14 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
|
|||
*/
|
||||
def script()
|
||||
|
||||
/**
|
||||
* A default handler for the onExecutionDone() function. By default this doesn't do anything
|
||||
* except print out a fine status message.
|
||||
*/
|
||||
def onExecutionDone(jobs: List[QFunction], success: Boolean) {
|
||||
logger.info("Script %s with %d total jobs".format(if (success) "completed successfully" else "failed", jobs.size))
|
||||
}
|
||||
|
||||
/**
|
||||
* The command line functions that will be executed for this QScript.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue