Skip to content
Snippets Groups Projects
Commit 011f6de7 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Adds Popen option to run_commandline

parent 4dbb39aa
No related branches found
No related tags found
No related merge requests found
......@@ -191,7 +191,7 @@ def compute_pstar(twoFcheck_obs, twoFstarcheck_obs, m0, plot=False):
return 2*np.min([pstar_l, 1-pstar_l])
def run_commandline(cl, log_level=20, raise_error=True):
def run_commandline(cl, log_level=20, raise_error=True, return_output=True):
"""Run a string cmd as a subprocess, check for errors and return output.
Parameters
......@@ -205,11 +205,12 @@ def run_commandline(cl, log_level=20, raise_error=True):
"""
logging.log(log_level, 'Now executing: ' + cl)
if return_output:
try:
out = subprocess.check_output(cl, # what to run
stderr=subprocess.STDOUT, # catch errors
shell=True, # proper environment etc
universal_newlines=True # properly display linebreaks in error/output printing
universal_newlines=True, # properly display linebreaks in error/output printing
)
except subprocess.CalledProcessError as e:
logging.log(log_level, 'Execution failed: {}'.format(e.output))
......@@ -218,8 +219,11 @@ def run_commandline(cl, log_level=20, raise_error=True):
else:
out = 0
os.system('\n')
return(out)
else:
process = subprocess.Popen(cl, shell=True)
process.communicate()
def convert_array_to_gsl_matrix(array):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment