Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gregory Ashton
PyFstat
Commits
011f6de7
Commit
011f6de7
authored
Aug 04, 2017
by
Gregory Ashton
Browse files
Adds Popen option to run_commandline
parent
4dbb39aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
pyfstat/helper_functions.py
View file @
011f6de7
...
...
@@ -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,21 +205,25 @@ def run_commandline(cl, log_level=20, raise_error=True):
"""
logging
.
log
(
log_level
,
'Now executing: '
+
cl
)
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
)
except
subprocess
.
CalledProcessError
as
e
:
logging
.
log
(
log_level
,
'Execution failed: {}'
.
format
(
e
.
output
))
if
raise_error
:
raise
else
:
out
=
0
os
.
system
(
'
\n
'
)
return
(
out
)
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
)
except
subprocess
.
CalledProcessError
as
e
:
logging
.
log
(
log_level
,
'Execution failed: {}'
.
format
(
e
.
output
))
if
raise_error
:
raise
else
:
out
=
0
os
.
system
(
'
\n
'
)
return
(
out
)
else
:
process
=
subprocess
.
Popen
(
cl
,
shell
=
True
)
process
.
communicate
()
def
convert_array_to_gsl_matrix
(
array
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment