Commit 23ed7d86 authored by Timothee Chabat's avatar Timothee Chabat
Browse files

add command line process proxy

parent f55e64b4
......@@ -673,6 +673,34 @@
<!-- End of TimerLog -->
</Proxy>
<Proxy class="vtkCommandLineProcess"
name="CommandLineProcess"
processes="client|dataserver|renderserver">
<Documentation>Execute a process on server side.</Documentation>
<Property command="Execute"
name="Execute">
<Documentation>Resets the log on all processes.</Documentation>
</Property>
<StringVectorProperty command="SetCommand"
default_values=""
name="Command">
<Documentation>Set the command to execute.</Documentation>
</StringVectorProperty>
<StringVectorProperty command="GetStdOut"
name="StdOut"
number_of_elements="1"
information_only="1">
<Documentation>Get the standard output of the command.</Documentation>
</StringVectorProperty>
<StringVectorProperty command="GetStdErr"
name="StdErr"
number_of_elements="1"
information_only="1">
<Documentation>Get the error output of the command.</Documentation>
</StringVectorProperty>
<!-- End of CommandLineProcess -->
</Proxy>
<!-- ================================================================= -->
<Proxy name="LogRecorder" class="vtkLogRecorder">
<IntVectorProperty name="RankEnabled"
......
vtk_add_test_cxx(vtkRemotingCoreCxxTests tests
NO_DATA NO_VALID NO_OUTPUT
TestCommandLineProcess.cxx
TestPartialArraysInformation.cxx
TestPVArrayInformation.cxx
TestSpecialDirectories.cxx
......
/*=========================================================================
Program: ParaView
Module: TestCommandLineProcess.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkInitializationHelper.h"
#include "vtkNew.h"
#include "vtkProcessModule.h"
#include "vtkSMParaViewPipelineController.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxy.h"
#include "vtkSMSession.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include <string>
int TestCommandLineProcess(int argc, char* argv[])
{
vtkInitializationHelper::SetApplicationName("TestCommandLineProcess");
vtkInitializationHelper::SetOrganizationName("Humanity");
vtkInitializationHelper::Initialize(argv[0], vtkProcessModule::PROCESS_CLIENT);
vtkNew<vtkSMParaViewPipelineController> controller;
vtkNew<vtkSMSession> session;
// Register the session with the process module.
vtkProcessModule::GetProcessModule()->RegisterSession(session.Get());
// Initializes a session and setups all basic proxies that are needed for a
// ParaView-like application.
controller->InitializeSession(session.Get());
// Setup a proxy to a command line process
vtkSMSessionProxyManager* pxm = session->GetSessionProxyManager();
vtkSmartPointer<vtkSMProxy> proxy;
proxy.TakeReference(pxm->NewProxy("misc", "CommandLineProcess"));
if (!proxy)
{
vtkGenericWarningMacro("Failed to create proxy: `misc,CommandLineProcess`. Aborting !!!");
abort();
}
// Call a command line process
vtkSMPropertyHelper(proxy->GetProperty("Command")).Set("echo Hello World");
proxy->UpdateVTKObjects();
proxy->InvokeCommand("Execute");
auto* outProp = proxy->GetProperty("StdOut");
proxy->UpdatePropertyInformation(outProp);
std::string result = vtkSMPropertyHelper(outProp).GetAsString();
// Check if output is good
if (result != "Hello World")
{
vtkGenericWarningMacro("Wrong output, command line failed. Expected: 'Hello World', received: '" << result << "'");
abort();
}
// Unregistering pipeline proxies will also release any representations
// created for these proxies.
controller->UnRegisterProxy(proxy);
vtkProcessModule::GetProcessModule()->UnRegisterSession(session.Get());
vtkInitializationHelper::Finalize();
return 0;
}
......@@ -28,6 +28,7 @@ OPTIONAL_DEPENDS
VTK::PythonInterpreter
VTK::WrappingPythonCore
TEST_DEPENDS
ParaView::RemotingApplication
VTK::FiltersSources
VTK::TestingCore
TEST_LABELS
......
Subproject commit 917fc1a2bd91796b2818edad5f2245b5de2e0519
Subproject commit eb8e6840c673cc942e21bdf565cdb4a36d872651
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment