Created
February 6, 2013 22:21
-
-
Save jcfr/4726448 to your computer and use it in GitHub Desktop.
Example illustrating how a cli could be executed directly using subprocess.Popen. This could be particularly useful when investigating issue associated with CLI.
Source: http://stackoverflow.com/questions/706989/how-to-call-an-external-program-in-python-and-retrieve-the-output-and-return-cod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from subprocess import Popen, PIPE | |
#cli_path = "/home/jchris/Projects/Slicer-AHM-Superbuild-Debug/Slicer-build/lib/Slicer-4.2/cli-modules" | |
#cli_name = "AddScalarVolumes" | |
#cli_filepath = os.path.join(cli_path, cli_name) | |
cli_filepath = slicer.modules.addscalarvolumes.path | |
process = Popen([cli_filepath, "--xml"], stdout=PIPE) | |
output = process.communicate()[0] | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since my module was not loading in Slicer, I had to use the commented piece of code and comment out "slicer.modules.addscalarvolumes.path". Very useful though!