use of org.eclipse.scanning.api.script.ScriptRequest in project gda-core by openGDA.
the class FrameCaptureRequestHandler method internalHandling.
private boolean internalHandling(FrameCaptureRequest frameCaptureRequest, ScanRequest scanRequest) {
List<FrameRequestDocument> detectorDocuments = frameCaptureRequest.getValue();
String monitorName = serverProperties.getProcessingRequests().getFrameCaptureDecorator();
if (monitorName == null) {
logger.error("Frame capture decorator not defined");
return false;
}
try {
FrameCollectingScannable scn = (FrameCollectingScannable) ScannableDeviceConnectorService.getInstance().getScannable(monitorName);
scn.setFrameRequestDocument(detectorDocuments.iterator().next());
} catch (ScanningException e) {
logger.error("Error retrieving {} '{}'", FrameCollectingScannable.class.getName(), monitorName, e);
return false;
}
List<String> monitors = new ArrayList<>(scanRequest.getMonitorNamesPerScan());
monitors.add(monitorName);
scanRequest.setMonitorNamesPerScan(monitors);
var script = LocalProperties.get(CAMERA_STREAM_SCRIPT_PROPERTY);
if (script != null) {
var scriptRequest = new ScriptRequest(script);
scanRequest.setAfterScript(scriptRequest);
}
return true;
}
use of org.eclipse.scanning.api.script.ScriptRequest in project gda-core by openGDA.
the class GDAJythonScriptServiceTest method testExecute.
@Test
public void testExecute() throws Exception {
File testFile = File.createTempFile("test", ".py", null);
testFile.deleteOnExit();
String testFilePath = testFile.getAbsolutePath();
ScriptRequest scriptRequest = new ScriptRequest(testFilePath, SPEC_PASTICHE);
scriptService.execute(scriptRequest);
verify(mockCommandRunner).evaluateCommand("run '" + testFilePath + "'");
}
use of org.eclipse.scanning.api.script.ScriptRequest in project gda-core by openGDA.
the class GDAJythonScriptServiceTest method testExecuteNoSuchFile.
@Test(expected = ScriptExecutionException.class)
public void testExecuteNoSuchFile() throws Exception {
ICommandRunner mockCommandRunner = Mockito.mock(ICommandRunner.class);
InterfaceProvider.setCommandRunnerForTesting(mockCommandRunner);
ScriptRequest scriptRequest = new ScriptRequest("/tmp/noSuchFile.py", SPEC_PASTICHE);
scriptService.execute(scriptRequest);
}
Aggregations