-
Notifications
You must be signed in to change notification settings - Fork 1.4k
refactor commands/scripts to expose only one named mne #866
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import glob | ||
import subprocess | ||
import os.path as op | ||
|
||
import mne | ||
|
||
mne_bin_dir = op.dirname(mne.__file__) | ||
valid_commands = sorted(glob.glob(op.join(mne_bin_dir, 'commands', 'mne_*.py'))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filtering is not needed here, os.listdir will be 50 % faster |
||
valid_commands = [c.split(op.sep)[-1][4:-3] for c in valid_commands] | ||
|
||
def print_help(): | ||
print "Usage : mne command options\n" | ||
print "Accepted commands :\n" | ||
for c in valid_commands: | ||
print "\t- %s" % c | ||
print "\nExample : mne browse_raw --raw sample_audvis_raw.fif" | ||
print "\nGetting help example : mne compute_proj_eog -h" | ||
sys.exit(0) | ||
|
||
if len(sys.argv) == 1: | ||
print_help() | ||
elif ("help" in sys.argv[1] or "-h" in sys.argv[1]): | ||
print_help() | ||
elif sys.argv[1] == "--version": | ||
print "MNE %s" % mne.__version__ | ||
elif sys.argv[1] not in valid_commands: | ||
print 'Invalid command: "%s"\n' % sys.argv[1] | ||
print_help() | ||
sys.exit(0) | ||
else: | ||
cmd = sys.argv[1] | ||
cmd_path = op.join(mne_bin_dir, 'commands', 'mne_%s.py' % cmd) | ||
p = subprocess.Popen([cmd_path] + sys.argv[2:], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE) | ||
stdout, stderr = p.communicate() | ||
if stdout.startswith('Usage'): | ||
stdout = stdout.replace("mne_", "mne ") | ||
stdout = stdout.replace(".py", "") | ||
if p.returncode: | ||
print stderr, stdout | ||
else: | ||
print stdout |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#! /usr/bin/env python | ||
# | ||
# Copyright (C) 2011 Alexandre Gramfort <gramfort@nmr.mgh.harvard.edu> | ||
# Copyright (C) 2011-2013 Alexandre Gramfort <gramfort@nmr.mgh.harvard.edu> | ||
|
||
import os | ||
import mne | ||
|
@@ -67,14 +67,11 @@ | |
'mne.tests', | ||
'mne.stats', 'mne.stats.tests', | ||
'mne.time_frequency', 'mne.time_frequency.tests', | ||
'mne.realtime', 'mne.realtime.tests', 'mne.decoding', | ||
'mne.decoding.tests'], | ||
'mne.realtime', 'mne.realtime.tests', | ||
'mne.decoding', 'mne.decoding.tests', | ||
'mne.commands'], | ||
package_data={'mne': ['data/*.sel', | ||
'data/icos.fif.gz', | ||
'data/coil_def.dat', | ||
'layouts/*.lout']}, | ||
scripts=['bin/mne_clean_eog_ecg.py', 'bin/mne_flash_bem_model.py', | ||
'bin/mne_surf2bem.py', 'bin/mne_compute_proj_ecg.py', | ||
'bin/mne_compute_proj_eog.py', 'bin/mne_maxfilter.py', | ||
'bin/mne_bti2fiff.py', 'bin/mne_kit2fiff.py', | ||
'bin/mne_browse_raw.py', 'bin/mne_make_scalp_surfaces.py']) | ||
scripts=['bin/mne']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't original MNE have an 'mne' cmdline? or is it a proper 'MNE'? ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Fri, 01 Nov 2013, Eric89GXL wrote:
the idea is to have only 1 public level script (consider git) which Yaroslav O. Halchenko, Ph.D. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know -- I was responding to your comment asking if the original MNE had an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah -- fault is mine + github. In the email I replied to it was just code and your answer without my question which I successfully forgotten to have placed at that point ;) so -- thanks! happen stock MNE comes up with its cmdline single command, could we pursuade them to make it e.g. capitalcased? ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but still, will this -- as proposed -- resove the name space issue? Wasn't the initial proposal to have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should think about optimizing import speed. it takes too long to wait for the help print