Skip to content
This repository

Modifications to profile list #1176

Merged
merged 2 commits into from over 2 years ago

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 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 December 18, 2011
Fernando Perez fperez closed this December 18, 2011
Fernando Perez fperez referenced this pull request from a commit January 10, 2012
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

Showing 2 unique commits by 1 author.

Dec 18, 2011
Min RK Modifications to profile list
Includes bundled profiles in `ipython profile list` output,
and segments output into: bundled, IPYTHONDIR, cwd.
fdc48d5
Min RK profile list prints just profile names cebfd05
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 54 additions and 14 deletions. Show diff stats Hide diff stats

  1. 68  IPython/core/profileapp.py
68  IPython/core/profileapp.py
@@ -29,7 +29,7 @@
29 29
     BaseIPythonApplication, base_flags, base_aliases
30 30
 )
31 31
 from IPython.core.profiledir import ProfileDir
32  
-from IPython.utils.path import get_ipython_dir
  32
+from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
33 33
 from IPython.utils.traitlets import Unicode, Bool, Dict
34 34
 
35 35
 #-----------------------------------------------------------------------------
@@ -115,20 +115,60 @@ class ProfileList(Application):
115 115
         the environment variable IPYTHON_DIR.
116 116
         """
117 117
     )
118  
-
  118
+    
  119
+    def _list_profiles_in(self, path):
  120
+        """list profiles in a given root directory"""
  121
+        files = os.listdir(path)
  122
+        profiles = []
  123
+        for f in files:
  124
+            full_path = os.path.join(path, f)
  125
+            if os.path.isdir(full_path) and f.startswith('profile_'):
  126
+                profiles.append(f.split('_',1)[-1])
  127
+        return profiles
  128
+    
  129
+    def _list_bundled_profiles(self):
  130
+        """list profiles in a given root directory"""
  131
+        path = os.path.join(get_ipython_package_dir(), u'config', u'profile')
  132
+        files = os.listdir(path)
  133
+        profiles = []
  134
+        for profile in files:
  135
+            full_path = os.path.join(path, profile)
  136
+            if os.path.isdir(full_path):
  137
+                profiles.append(profile)
  138
+        return profiles
  139
+    
  140
+    def _print_profiles(self, profiles):
  141
+        """print list of profiles, indented."""
  142
+        for profile in profiles:
  143
+            print '    %s' % profile
  144
+    
119 145
     def list_profile_dirs(self):
120  
-        # Find the search paths
121  
-        paths = [os.getcwdu(), self.ipython_dir]
122  
-
123  
-        self.log.warn('Searching for IPython profiles in paths: %r' % paths)
124  
-        for path in paths:
125  
-            files = os.listdir(path)
126  
-            for f in files:
127  
-                full_path = os.path.join(path, f)
128  
-                if os.path.isdir(full_path) and f.startswith('profile_'):
129  
-                    profile = f.split('_',1)[-1]
130  
-                    start_cmd = 'ipython --profile=%s' % profile
131  
-                    print start_cmd + " ==> " + full_path
  146
+        profiles = self._list_bundled_profiles()
  147
+        if profiles:
  148
+            print
  149
+            print "Available profiles in IPython:"
  150
+            self._print_profiles(profiles)
  151
+            print
  152
+            print "    The first request for a bundled profile will copy it"
  153
+            print "    into your IPython directory (%s)," % self.ipython_dir
  154
+            print "    where you can customize it."
  155
+        
  156
+        profiles = self._list_profiles_in(self.ipython_dir)
  157
+        if profiles:
  158
+            print
  159
+            print "Available profiles in %s:" % self.ipython_dir
  160
+            self._print_profiles(profiles)
  161
+        
  162
+        profiles = self._list_profiles_in(os.getcwdu())
  163
+        if profiles:
  164
+            print
  165
+            print "Available profiles in current directory (%s):" % os.getcwdu()
  166
+            self._print_profiles(profiles)
  167
+        
  168
+        print
  169
+        print "To use any of the above profiles, start IPython with:"
  170
+        print "    ipython --profile=<name>"
  171
+        print
132 172
 
133 173
     def start(self):
134 174
         self.list_profile_dirs()
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.