Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyFstat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gregory Ashton
PyFstat
Commits
011f6de7
Commit
011f6de7
authored
7 years ago
by
Gregory Ashton
Browse files
Options
Downloads
Patches
Plain Diff
Adds Popen option to run_commandline
parent
4dbb39aa
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyfstat/helper_functions.py
+20
-16
20 additions, 16 deletions
pyfstat/helper_functions.py
with
20 additions
and
16 deletions
pyfstat/helper_functions.py
+
20
−
16
View file @
011f6de7
...
@@ -191,7 +191,7 @@ def compute_pstar(twoFcheck_obs, twoFstarcheck_obs, m0, plot=False):
...
@@ -191,7 +191,7 @@ def compute_pstar(twoFcheck_obs, twoFstarcheck_obs, m0, plot=False):
return
2
*
np
.
min
([
pstar_l
,
1
-
pstar_l
])
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.
"""
Run a string cmd as a subprocess, check for errors and return output.
Parameters
Parameters
...
@@ -205,11 +205,12 @@ def run_commandline(cl, log_level=20, raise_error=True):
...
@@ -205,11 +205,12 @@ def run_commandline(cl, log_level=20, raise_error=True):
"""
"""
logging
.
log
(
log_level
,
'
Now executing:
'
+
cl
)
logging
.
log
(
log_level
,
'
Now executing:
'
+
cl
)
if
return_output
:
try
:
try
:
out
=
subprocess
.
check_output
(
cl
,
# what to run
out
=
subprocess
.
check_output
(
cl
,
# what to run
stderr
=
subprocess
.
STDOUT
,
# catch errors
stderr
=
subprocess
.
STDOUT
,
# catch errors
shell
=
True
,
# proper environment etc
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
:
except
subprocess
.
CalledProcessError
as
e
:
logging
.
log
(
log_level
,
'
Execution failed: {}
'
.
format
(
e
.
output
))
logging
.
log
(
log_level
,
'
Execution failed: {}
'
.
format
(
e
.
output
))
...
@@ -218,8 +219,11 @@ def run_commandline(cl, log_level=20, raise_error=True):
...
@@ -218,8 +219,11 @@ def run_commandline(cl, log_level=20, raise_error=True):
else
:
else
:
out
=
0
out
=
0
os
.
system
(
'
\n
'
)
os
.
system
(
'
\n
'
)
return
(
out
)
return
(
out
)
else
:
process
=
subprocess
.
Popen
(
cl
,
shell
=
True
)
process
.
communicate
()
def
convert_array_to_gsl_matrix
(
array
):
def
convert_array_to_gsl_matrix
(
array
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment