1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* continued work on porting ScriptShell to the new extension mechanism

This commit is contained in:
Reinhard Pointner 2014-04-16 08:52:57 +00:00
parent 8945478a6b
commit 68df1b7c09

View File

@ -27,12 +27,26 @@ public abstract class ScriptShellBaseClass extends Script {
System.out.println(this);
}
public void include(String input) throws Throwable {
try {
executeScript(input, null);
} catch (Exception e) {
printException(e);
}
}
public Object executeScript(String input) throws Throwable {
return executeScript(input, null);
}
public Object executeScript(String input, Map<String, ?> bindings, Object... args) throws Throwable {
// apply parent script defines
Bindings parameters = new SimpleBindings();
// initialize default parameter
parameters.putAll(bindings);
if (bindings != null) {
parameters.putAll(bindings);
}
parameters.put(ScriptShell.ARGV_BINDING_NAME, asFileList(args));
// run given script
@ -77,11 +91,19 @@ public abstract class ScriptShellBaseClass extends Script {
try {
return c.call();
} catch (Exception e) {
CLILogger.severe(String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()));
printException(e);
return null;
}
}
public void printException(Throwable t) {
CLILogger.severe(String.format("%s: %s", t.getClass().getSimpleName(), t.getMessage()));
}
public void die(String message) throws Throwable {
throw new Exception(message);
}
@Override
public Object run() {
return null;