Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] change utils.logger.warning -> utils.warn #9434

Merged
merged 5 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mne/gui/_coreg_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
from ..coreg import fit_matched_points, scale_mri, _find_fiducials_files
from ..viz.backends._pysurfer_mayavi import _toggle_mlab_render
from ..viz._3d import _get_3d_option
from ..utils import logger, set_config, _pl
from ..utils import logger, set_config, _pl, warn
from ._fiducials_gui import MRIHeadWithFiducialsModel, FiducialsPanel
from ._file_traits import trans_wildcard, DigSource, SubjectSelectorPanel
from ._viewer import (HeadViewController, PointObject, SurfaceObject,
Expand Down Expand Up @@ -895,7 +895,7 @@ def close(self, info, is_ok):
try:
info.object.save_config(size=size)
except Exception as exc:
warnings.warn("Error saving GUI configuration:\n%s" % (exc,))
warn("Error saving GUI configuration:\n%s" % (exc,))
return True


Expand Down
4 changes: 2 additions & 2 deletions mne/io/brainvision/brainvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ def _get_vhdr_info(vhdr_fname, eog, misc, scale):
try:
n_samples = cfg.getint(cinfostr, 'DataPoints')
except configparser.NoOptionError:
logger.warning('No info on DataPoints found. Inferring number of '
'samples from the data file size.')
warn('No info on DataPoints found. Inferring number of '
'samples from the data file size.')
with open(data_fname, 'rb') as fid:
fid.seek(0, 2)
n_bytes = fid.tell()
Expand Down
2 changes: 1 addition & 1 deletion mne/io/kit/kit.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def get_kit_info(rawfile, allow_unknown_format, standardize_names=None,
version_string = "V%iR%03i" % (version, revision)
if allow_unknown_format:
unsupported_format = True
logger.warning("Force loading KIT format %s", version_string)
warn("Force loading KIT format %s", version_string)
else:
raise UnsupportedKITFormat(
version_string,
Expand Down
10 changes: 7 additions & 3 deletions mne/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def run_subprocess(command, return_code=False, verbose=None, *args, **kwargs):
# non-blocking adapted from https://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python#4896288 # noqa: E501
out_q = Queue()
err_q = Queue()
with running_subprocess(command, *args, **kwargs) as p:
with running_subprocess(command, *args, **kwargs) as p, p.stdout, p.stderr:
out_t = Thread(target=_enqueue_output, args=(p.stdout, out_q))
err_t = Thread(target=_enqueue_output, args=(p.stderr, err_q))
out_t.daemon = True
Expand All @@ -149,12 +149,16 @@ def run_subprocess(command, return_code=False, verbose=None, *args, **kwargs):
break
else:
err = err.decode('utf-8')
# Leave this as logger.warning rather than warn(...) to
# mirror the logger.info above for stdout. This function
# is basically just a version of subprocess.call, and
# shouldn't emit Python warnings due to stderr outputs
# (the calling function can check for stderr output and
# emit a warning if it wants).
logger.warning(err)
all_err += err
if do_break:
break
p.stdout.close()
p.stderr.close()
output = (all_out, all_err)

if return_code:
Expand Down