Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Modifications to profile list #1176

Merged
merged 2 commits into from

2 participants

Min RK Fernando Perez
Min RK
Owner

Includes bundled profiles in ipython profile list output,
and segments output into: bundled, ipdir, cwd.

Per @fperez suggestion

Sample output:

minrk@Mercury[14:10]~/dev/ip/mine (profilelist) $ ipython profile list

Available profiles in IPython:
    ipython --profile=cluster
    ipython --profile=math
    ipython --profile=pysh
    ipython --profile=python3
    ipython --profile=sympy

    The first request for a bundled profile will copy it
    into your IPython directory (/Users/minrk/.ipython),
    where you can customize it to your needs.

Available profiles in /Users/minrk/.ipython:
    ipython --profile=0.11
    ipython --profile=cluster
    ipython --profile=default
    ipython --profile=foo
    ipython --profile=food
    ipython --profile=fresh
    ipython --profile=føø
    ipython --profile=go
    ipython --profile=iptest
    ipython --profile=math
    ipython --profile=mpi
    ipython --profile=neuro
    ipython --profile=password
    ipython --profile=pylab
    ipython --profile=pysh
    ipython --profile=python3
    ipython --profile=sge
    ipython --profile=sh
    ipython --profile=ssh
    ipython --profile=sympy
    ipython --profile=temp

Available profiles in current directory (/Users/minrk/dev/ip/mine):
    ipython --profile=carrot
Min RK minrk Modifications to profile list
Includes bundled profiles in `ipython profile list` output,
and segments output into: bundled, IPYTHONDIR, cwd.
fdc48d5
Fernando Perez
Owner

While I see the copy/paste value of printing them this way, I think it makes for a busy layout. How about we just print the profile names alone, and at the bottom print a single explanation line that says something like

```To use any of the above profiles, use

ipython --profile


I think it would make for a more easy to read output.
Min RK
Owner

I like the copy/paste format a tiny bit better, but I'll defer to you. Pushed with recommended change.

Fernando Perez
Owner

I love it, thanks a lot. Will complete running the test suite locally, and if all passes will merge it right away.

Fernando Perez fperez merged commit c5e6514 into from
Fernando Perez fperez referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 18, 2011
  1. Min RK

    Modifications to profile list

    minrk authored
    Includes bundled profiles in `ipython profile list` output,
    and segments output into: bundled, IPYTHONDIR, cwd.
  2. Min RK
This page is out of date. Refresh to see the latest.
Showing with 54 additions and 14 deletions.
  1. +54 −14 IPython/core/profileapp.py
68 IPython/core/profileapp.py
View
@@ -29,7 +29,7 @@
BaseIPythonApplication, base_flags, base_aliases
)
from IPython.core.profiledir import ProfileDir
-from IPython.utils.path import get_ipython_dir
+from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
from IPython.utils.traitlets import Unicode, Bool, Dict
#-----------------------------------------------------------------------------
@@ -115,20 +115,60 @@ class ProfileList(Application):
the environment variable IPYTHON_DIR.
"""
)
-
+
+ def _list_profiles_in(self, path):
+ """list profiles in a given root directory"""
+ files = os.listdir(path)
+ profiles = []
+ for f in files:
+ full_path = os.path.join(path, f)
+ if os.path.isdir(full_path) and f.startswith('profile_'):
+ profiles.append(f.split('_',1)[-1])
+ return profiles
+
+ def _list_bundled_profiles(self):
+ """list profiles in a given root directory"""
+ path = os.path.join(get_ipython_package_dir(), u'config', u'profile')
+ files = os.listdir(path)
+ profiles = []
+ for profile in files:
+ full_path = os.path.join(path, profile)
+ if os.path.isdir(full_path):
+ profiles.append(profile)
+ return profiles
+
+ def _print_profiles(self, profiles):
+ """print list of profiles, indented."""
+ for profile in profiles:
+ print ' %s' % profile
+
def list_profile_dirs(self):
- # Find the search paths
- paths = [os.getcwdu(), self.ipython_dir]
-
- self.log.warn('Searching for IPython profiles in paths: %r' % paths)
- for path in paths:
- files = os.listdir(path)
- for f in files:
- full_path = os.path.join(path, f)
- if os.path.isdir(full_path) and f.startswith('profile_'):
- profile = f.split('_',1)[-1]
- start_cmd = 'ipython --profile=%s' % profile
- print start_cmd + " ==> " + full_path
+ profiles = self._list_bundled_profiles()
+ if profiles:
+ print
+ print "Available profiles in IPython:"
+ self._print_profiles(profiles)
+ print
+ print " The first request for a bundled profile will copy it"
+ print " into your IPython directory (%s)," % self.ipython_dir
+ print " where you can customize it."
+
+ profiles = self._list_profiles_in(self.ipython_dir)
+ if profiles:
+ print
+ print "Available profiles in %s:" % self.ipython_dir
+ self._print_profiles(profiles)
+
+ profiles = self._list_profiles_in(os.getcwdu())
+ if profiles:
+ print
+ print "Available profiles in current directory (%s):" % os.getcwdu()
+ self._print_profiles(profiles)
+
+ print
+ print "To use any of the above profiles, start IPython with:"
+ print " ipython --profile=<name>"
+ print
def start(self):
self.list_profile_dirs()
Something went wrong with that request. Please try again.