@@ -19,6 +19,7 @@ public class Jvcl extends BaseMain<JvclOptions> { | |||||
@Override protected void run() throws Exception { | @Override protected void run() throws Exception { | ||||
final JvclOptions options = getOptions(); | final JvclOptions options = getOptions(); | ||||
final JSpec spec = options.getSpec(); | final JSpec spec = options.getSpec(); | ||||
final boolean noExec = options.isNoExec(); | |||||
if (empty(spec.getAssets())) { | if (empty(spec.getAssets())) { | ||||
err(">>> jvcl: no assets defined in spec"); | err(">>> jvcl: no assets defined in spec"); | ||||
@@ -34,7 +35,7 @@ public class Jvcl extends BaseMain<JvclOptions> { | |||||
final AssetManager assetManager = new AssetManager(toolbox, getOptions().scratchDir()); | final AssetManager assetManager = new AssetManager(toolbox, getOptions().scratchDir()); | ||||
Arrays.stream(spec.getAssets()).forEach(assetManager::defineAsset); | Arrays.stream(spec.getAssets()).forEach(assetManager::defineAsset); | ||||
final OperationEngine opEngine = new OperationEngine(toolbox, assetManager); | |||||
final OperationEngine opEngine = new OperationEngine(toolbox, assetManager, noExec); | |||||
Arrays.stream(spec.getOperations()).forEach(opEngine::perform); | Arrays.stream(spec.getOperations()).forEach(opEngine::perform); | ||||
final int opCount = spec.getOperations().length; | final int opCount = spec.getOperations().length; | ||||
@@ -31,6 +31,7 @@ public abstract class JOperation { | |||||
@Getter @Setter private String operation; | @Getter @Setter private String operation; | ||||
@Getter @Setter private JsonNode creates; | @Getter @Setter private JsonNode creates; | ||||
@Getter @Setter private boolean noExec = false; | |||||
public String hash(JAsset[] sources) { return hash(sources, null); } | public String hash(JAsset[] sources) { return hash(sources, null); } | ||||
@@ -14,7 +14,6 @@ import java.util.List; | |||||
import java.util.Map; | import java.util.Map; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class ConcatExec extends ExecBase<ConcatOperation> { | public class ConcatExec extends ExecBase<ConcatOperation> { | ||||
@@ -51,7 +50,7 @@ public class ConcatExec extends ExecBase<ConcatOperation> { | |||||
final String script = renderScript(toolbox, ctx, CONCAT_RECODE_TEMPLATE_1); | final String script = renderScript(toolbox, ctx, CONCAT_RECODE_TEMPLATE_1); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
assetManager.addOperationAsset(output); | assetManager.addOperationAsset(output); | ||||
} | } | ||||
@@ -12,6 +12,7 @@ import java.util.Map; | |||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
import static org.cobbzilla.util.io.FileUtil.basename; | import static org.cobbzilla.util.io.FileUtil.basename; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public abstract class ExecBase<OP extends JOperation> { | public abstract class ExecBase<OP extends JOperation> { | ||||
@@ -36,4 +37,13 @@ public abstract class ExecBase<OP extends JOperation> { | |||||
return defaultOutfile; | return defaultOutfile; | ||||
} | } | ||||
} | } | ||||
public String exec(String script, boolean noExec) { | |||||
if (noExec) { | |||||
System.out.println(script); | |||||
return ""; | |||||
} else { | |||||
return execScript(script); | |||||
} | |||||
} | |||||
} | } |
@@ -20,7 +20,6 @@ import static java.math.BigDecimal.ZERO; | |||||
import static jvcl.service.Toolbox.TWO; | import static jvcl.service.Toolbox.TWO; | ||||
import static jvcl.service.Toolbox.divideBig; | import static jvcl.service.Toolbox.divideBig; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class KenBurnsExec extends ExecBase<KenBurnsOperation> { | public class KenBurnsExec extends ExecBase<KenBurnsOperation> { | ||||
@@ -97,7 +96,7 @@ public class KenBurnsExec extends ExecBase<KenBurnsOperation> { | |||||
final String script = renderScript(toolbox, ctx, KEN_BURNS_TEMPLATE); | final String script = renderScript(toolbox, ctx, KEN_BURNS_TEMPLATE); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
assetManager.addOperationAsset(output); | assetManager.addOperationAsset(output); | ||||
} | } | ||||
@@ -14,7 +14,6 @@ import java.util.Map; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.die; | import static org.cobbzilla.util.daemon.ZillaRuntime.die; | ||||
import static org.cobbzilla.util.string.StringUtil.safeShellArg; | import static org.cobbzilla.util.string.StringUtil.safeShellArg; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class LetterboxExec extends SingleOrMultiSourceExecBase<LetterboxOperation> { | public class LetterboxExec extends SingleOrMultiSourceExecBase<LetterboxOperation> { | ||||
@@ -71,7 +70,7 @@ public class LetterboxExec extends SingleOrMultiSourceExecBase<LetterboxOperatio | |||||
final String script = renderScript(toolbox, ctx, LETTERBOX_TEMPLATE); | final String script = renderScript(toolbox, ctx, LETTERBOX_TEMPLATE); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
if (output == subOutput) { | if (output == subOutput) { | ||||
assetManager.addOperationAsset(output); | assetManager.addOperationAsset(output); | ||||
@@ -15,7 +15,6 @@ import java.util.HashMap; | |||||
import java.util.Map; | import java.util.Map; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class OverlayExec extends ExecBase<OverlayOperation> { | public class OverlayExec extends ExecBase<OverlayOperation> { | ||||
@@ -59,7 +58,7 @@ public class OverlayExec extends ExecBase<OverlayOperation> { | |||||
final String script = renderScript(toolbox, ctx, OVERLAY_TEMPLATE); | final String script = renderScript(toolbox, ctx, OVERLAY_TEMPLATE); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
assetManager.addOperationAsset(output); | assetManager.addOperationAsset(output); | ||||
} | } | ||||
@@ -13,8 +13,6 @@ import java.math.BigDecimal; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class ScaleExec extends SingleOrMultiSourceExecBase<ScaleOperation> { | public class ScaleExec extends SingleOrMultiSourceExecBase<ScaleOperation> { | ||||
@@ -58,7 +56,7 @@ public class ScaleExec extends SingleOrMultiSourceExecBase<ScaleOperation> { | |||||
final String script = renderScript(toolbox, ctx, SCALE_TEMPLATE); | final String script = renderScript(toolbox, ctx, SCALE_TEMPLATE); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
if (output == subOutput) { | if (output == subOutput) { | ||||
assetManager.addOperationAsset(output); | assetManager.addOperationAsset(output); | ||||
@@ -17,7 +17,6 @@ import java.util.Map; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.die; | import static org.cobbzilla.util.daemon.ZillaRuntime.die; | ||||
import static org.cobbzilla.util.io.FileUtil.abs; | import static org.cobbzilla.util.io.FileUtil.abs; | ||||
import static org.cobbzilla.util.io.FileUtil.mkdirOrDie; | import static org.cobbzilla.util.io.FileUtil.mkdirOrDie; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class SplitExec extends ExecBase<SplitOperation> { | public class SplitExec extends ExecBase<SplitOperation> { | ||||
@@ -76,7 +75,7 @@ public class SplitExec extends ExecBase<SplitOperation> { | |||||
final String script = renderScript(toolbox, ctx, SPLIT_TEMPLATE); | final String script = renderScript(toolbox, ctx, SPLIT_TEMPLATE); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
assetManager.addOperationAssetSlice(output, slice); | assetManager.addOperationAssetSlice(output, slice); | ||||
} | } | ||||
@@ -13,8 +13,6 @@ import java.math.BigDecimal; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | |||||
@Slf4j | @Slf4j | ||||
public class TrimExec extends SingleOrMultiSourceExecBase<TrimOperation> { | public class TrimExec extends SingleOrMultiSourceExecBase<TrimOperation> { | ||||
@@ -55,7 +53,7 @@ public class TrimExec extends SingleOrMultiSourceExecBase<TrimOperation> { | |||||
final String script = renderScript(toolbox, ctx, TRIM_TEMPLATE); | final String script = renderScript(toolbox, ctx, TRIM_TEMPLATE); | ||||
log.debug("operate: running script: "+script); | log.debug("operate: running script: "+script); | ||||
final String scriptOutput = execScript(script); | |||||
final String scriptOutput = exec(script, op.isNoExec()); | |||||
log.debug("operate: command output: "+scriptOutput); | log.debug("operate: command output: "+scriptOutput); | ||||
if (output == subOutput) { | if (output == subOutput) { | ||||
assetManager.addOperationAsset(output); | assetManager.addOperationAsset(output); | ||||
@@ -1,18 +1,21 @@ | |||||
package jvcl.service; | package jvcl.service; | ||||
import jvcl.model.operation.JOperation; | import jvcl.model.operation.JOperation; | ||||
import lombok.Getter; | |||||
public class OperationEngine { | public class OperationEngine { | ||||
private final Toolbox toolbox; | private final Toolbox toolbox; | ||||
private final AssetManager assetManager; | private final AssetManager assetManager; | ||||
@Getter private final boolean noExec; | |||||
public OperationEngine(Toolbox toolbox, AssetManager assetManager) { | |||||
public OperationEngine(Toolbox toolbox, AssetManager assetManager, boolean noExec) { | |||||
this.toolbox = toolbox; | this.toolbox = toolbox; | ||||
this.assetManager = assetManager; | this.assetManager = assetManager; | ||||
this.noExec = noExec; | |||||
} | } | ||||
public void perform(JOperation op) { | public void perform(JOperation op) { | ||||
op.getExec().operate(op, toolbox, assetManager); | |||||
op.setNoExec(noExec).getExec().operate(op, toolbox, assetManager); | |||||
} | } | ||||
} | } |