Show More
@@ -1,251 +1,258 b'' | |||||
1 | """Shell mode for IPython. |
|
1 | """Shell mode for IPython. | |
2 |
|
2 | |||
3 | Start ipython in shell mode by invoking "ipython -p sh" |
|
3 | Start ipython in shell mode by invoking "ipython -p sh" | |
4 |
|
4 | |||
5 | (the old version, "ipython -p pysh" still works but this is the more "modern" |
|
5 | (the old version, "ipython -p pysh" still works but this is the more "modern" | |
6 | shell mode and is recommended for users who don't care about pysh-mode |
|
6 | shell mode and is recommended for users who don't care about pysh-mode | |
7 | compatibility) |
|
7 | compatibility) | |
8 | """ |
|
8 | """ | |
9 |
|
9 | |||
10 | from IPython import ipapi |
|
10 | from IPython import ipapi | |
11 | import os,textwrap |
|
11 | import os,textwrap | |
12 |
|
12 | |||
13 | # The import below effectively obsoletes your old-style ipythonrc[.ini], |
|
13 | # The import below effectively obsoletes your old-style ipythonrc[.ini], | |
14 | # so consider yourself warned! |
|
14 | # so consider yourself warned! | |
15 |
|
15 | |||
16 | import ipy_defaults |
|
16 | import ipy_defaults | |
17 |
|
17 | |||
18 | def main(): |
|
18 | def main(): | |
19 | ip = ipapi.get() |
|
19 | ip = ipapi.get() | |
20 | o = ip.options |
|
20 | o = ip.options | |
21 | # autocall to "full" mode (smart mode is default, I like full mode) |
|
21 | # autocall to "full" mode (smart mode is default, I like full mode) | |
22 |
|
22 | |||
23 | o.autocall = 2 |
|
23 | o.autocall = 2 | |
24 |
|
24 | |||
25 | # Jason Orendorff's path class is handy to have in user namespace |
|
25 | # Jason Orendorff's path class is handy to have in user namespace | |
26 | # if you are doing shell-like stuff |
|
26 | # if you are doing shell-like stuff | |
27 | try: |
|
27 | try: | |
28 | ip.ex("from IPython.external.path import path" ) |
|
28 | ip.ex("from IPython.external.path import path" ) | |
29 | except ImportError: |
|
29 | except ImportError: | |
30 | pass |
|
30 | pass | |
31 |
|
31 | |||
32 | # beefed up %env is handy in shell mode |
|
32 | # beefed up %env is handy in shell mode | |
33 | import envpersist |
|
33 | import envpersist | |
34 |
|
34 | |||
35 | # To see where mycmd resides (in path/aliases), do %which mycmd |
|
35 | # To see where mycmd resides (in path/aliases), do %which mycmd | |
36 | import ipy_which |
|
36 | import ipy_which | |
37 |
|
37 | |||
38 | # tab completers for hg, svn, ... |
|
38 | # tab completers for hg, svn, ... | |
39 | import ipy_app_completers |
|
39 | import ipy_app_completers | |
40 |
|
40 | |||
41 | # To make executables foo and bar in mybin usable without PATH change, do: |
|
41 | # To make executables foo and bar in mybin usable without PATH change, do: | |
42 | # %rehashdir c:/mybin |
|
42 | # %rehashdir c:/mybin | |
43 | # %store foo |
|
43 | # %store foo | |
44 | # %store bar |
|
44 | # %store bar | |
45 | import ipy_rehashdir |
|
45 | import ipy_rehashdir | |
46 |
|
46 | |||
47 | # does not work without subprocess module! |
|
47 | # does not work without subprocess module! | |
48 | #import ipy_signals |
|
48 | #import ipy_signals | |
49 |
|
49 | |||
50 | ip.ex('import os') |
|
50 | ip.ex('import os') | |
51 | ip.ex("def up(): os.chdir('..')") |
|
51 | ip.ex("def up(): os.chdir('..')") | |
52 | ip.user_ns['LA'] = LastArgFinder() |
|
52 | ip.user_ns['LA'] = LastArgFinder() | |
53 | # Nice prompt |
|
53 | # Nice prompt | |
54 |
|
54 | |||
55 | o.prompt_in1= r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Green|\#> ' |
|
55 | o.prompt_in1= r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Green|\#> ' | |
56 | o.prompt_in2= r'\C_Green|\C_LightGreen\D\C_Green> ' |
|
56 | o.prompt_in2= r'\C_Green|\C_LightGreen\D\C_Green> ' | |
57 | o.prompt_out= '<\#> ' |
|
57 | o.prompt_out= '<\#> ' | |
58 |
|
58 | |||
59 | from IPython import Release |
|
59 | from IPython import Release | |
60 |
|
60 | |||
61 | import sys |
|
61 | import sys | |
62 | # Non-chatty banner |
|
62 | # Non-chatty banner | |
63 | o.banner = "IPython %s [on Py %s]\n" % (Release.version,sys.version.split(None,1)[0]) |
|
63 | o.banner = "IPython %s [on Py %s]\n" % (Release.version,sys.version.split(None,1)[0]) | |
64 |
|
64 | |||
65 |
|
65 | |||
66 | ip.IP.default_option('cd','-q') |
|
66 | ip.IP.default_option('cd','-q') | |
67 | ip.IP.default_option('macro', '-r') |
|
67 | ip.IP.default_option('macro', '-r') | |
68 | # If you only rarely want to execute the things you %edit... |
|
68 | # If you only rarely want to execute the things you %edit... | |
69 | #ip.IP.default_option('edit','-x') |
|
69 | #ip.IP.default_option('edit','-x') | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | o.prompts_pad_left="1" |
|
72 | o.prompts_pad_left="1" | |
73 | # Remove all blank lines in between prompts, like a normal shell. |
|
73 | # Remove all blank lines in between prompts, like a normal shell. | |
74 | o.separate_in="0" |
|
74 | o.separate_in="0" | |
75 | o.separate_out="0" |
|
75 | o.separate_out="0" | |
76 | o.separate_out2="0" |
|
76 | o.separate_out2="0" | |
77 |
|
77 | |||
78 | # now alias all syscommands |
|
78 | # now alias all syscommands | |
79 |
|
79 | |||
80 | db = ip.db |
|
80 | db = ip.db | |
81 |
|
81 | |||
82 | syscmds = db.get("syscmdlist",[] ) |
|
82 | syscmds = db.get("syscmdlist",[] ) | |
83 | if not syscmds: |
|
83 | if not syscmds: | |
84 | print textwrap.dedent(""" |
|
84 | print textwrap.dedent(""" | |
85 | System command list not initialized, probably the first run... |
|
85 | System command list not initialized, probably the first run... | |
86 | running %rehashx to refresh the command list. Run %rehashx |
|
86 | running %rehashx to refresh the command list. Run %rehashx | |
87 | again to refresh command list (after installing new software etc.) |
|
87 | again to refresh command list (after installing new software etc.) | |
88 | """) |
|
88 | """) | |
89 | ip.magic('rehashx') |
|
89 | ip.magic('rehashx') | |
90 | syscmds = db.get("syscmdlist") |
|
90 | syscmds = db.get("syscmdlist") | |
91 |
|
91 | |||
92 | # lowcase aliases on win32 only |
|
92 | # lowcase aliases on win32 only | |
93 | if os.name == 'posix': |
|
93 | if os.name == 'posix': | |
94 | mapper = lambda s:s |
|
94 | mapper = lambda s:s | |
95 | else: |
|
95 | else: | |
96 | def mapper(s): return s.lower() |
|
96 | def mapper(s): return s.lower() | |
97 |
|
97 | |||
98 | for cmd in syscmds: |
|
98 | for cmd in syscmds: | |
99 | # print "sys",cmd #dbg |
|
99 | # print "sys",cmd #dbg | |
100 | noext, ext = os.path.splitext(cmd) |
|
100 | noext, ext = os.path.splitext(cmd) | |
101 | key = mapper(noext) |
|
101 | key = mapper(noext) | |
102 | if key not in ip.IP.alias_table: |
|
102 | if key not in ip.IP.alias_table: | |
103 | ip.defalias(key, cmd) |
|
103 | ip.defalias(key, cmd) | |
104 |
|
104 | |||
105 | # mglob combines 'find', recursion, exclusion... '%mglob?' to learn more |
|
105 | # mglob combines 'find', recursion, exclusion... '%mglob?' to learn more | |
106 | ip.load("IPython.external.mglob") |
|
106 | ip.load("IPython.external.mglob") | |
107 |
|
107 | |||
108 | # win32 is crippled w/o cygwin, try to help it a little bit |
|
108 | # win32 is crippled w/o cygwin, try to help it a little bit | |
109 | if sys.platform == 'win32': |
|
109 | if sys.platform == 'win32': | |
110 | if 'cygwin' in os.environ['PATH'].lower(): |
|
110 | if 'cygwin' in os.environ['PATH'].lower(): | |
111 | # use the colors of cygwin ls (recommended) |
|
111 | # use the colors of cygwin ls (recommended) | |
112 | ip.defalias('d', 'ls -F --color=auto') |
|
112 | ip.defalias('d', 'ls -F --color=auto') | |
113 | else: |
|
113 | else: | |
114 | # get icp, imv, imkdir, igrep, irm,... |
|
114 | # get icp, imv, imkdir, igrep, irm,... | |
115 | ip.load('ipy_fsops') |
|
115 | ip.load('ipy_fsops') | |
116 |
|
116 | |||
117 | # and the next best thing to real 'ls -F' |
|
117 | # and the next best thing to real 'ls -F' | |
118 | ip.defalias('d','dir /w /og /on') |
|
118 | ip.defalias('d','dir /w /og /on') | |
119 |
|
119 | |||
|
120 | ip.set_hook('input_prefilter', dotslash_prefilter_f) | |||
120 | extend_shell_behavior(ip) |
|
121 | extend_shell_behavior(ip) | |
121 |
|
122 | |||
122 | class LastArgFinder: |
|
123 | class LastArgFinder: | |
123 | """ Allow $LA to work as "last argument of previous command", like $! in bash |
|
124 | """ Allow $LA to work as "last argument of previous command", like $! in bash | |
124 |
|
125 | |||
125 | To call this in normal IPython code, do LA() |
|
126 | To call this in normal IPython code, do LA() | |
126 | """ |
|
127 | """ | |
127 | def __call__(self, hist_idx = None): |
|
128 | def __call__(self, hist_idx = None): | |
128 | ip = ipapi.get() |
|
129 | ip = ipapi.get() | |
129 | if hist_idx is None: |
|
130 | if hist_idx is None: | |
130 | return str(self) |
|
131 | return str(self) | |
131 | return ip.IP.input_hist_raw[hist_idx].strip().split()[-1] |
|
132 | return ip.IP.input_hist_raw[hist_idx].strip().split()[-1] | |
132 | def __str__(self): |
|
133 | def __str__(self): | |
133 | ip = ipapi.get() |
|
134 | ip = ipapi.get() | |
134 | for cmd in reversed(ip.IP.input_hist_raw): |
|
135 | for cmd in reversed(ip.IP.input_hist_raw): | |
135 | parts = cmd.strip().split() |
|
136 | parts = cmd.strip().split() | |
136 | if len(parts) < 2 or parts[-1] in ['$LA', 'LA()']: |
|
137 | if len(parts) < 2 or parts[-1] in ['$LA', 'LA()']: | |
137 | continue |
|
138 | continue | |
138 | return parts[-1] |
|
139 | return parts[-1] | |
139 | return "" |
|
140 | return "" | |
140 |
|
141 | |||
141 |
|
142 | def dotslash_prefilter_f(self,line): | ||
142 |
|
143 | """ ./foo now runs foo as system command | ||
143 |
|
144 | |||
|
145 | Removes the need for doing !./foo | |||
|
146 | """ | |||
|
147 | import IPython.genutils | |||
|
148 | if line.startswith("./"): | |||
|
149 | return "_ip.system(" + IPython.genutils.make_quoted_expr(line)+")" | |||
|
150 | raise ipapi.TryNext | |||
144 |
|
151 | |||
145 | # XXX You do not need to understand the next function! |
|
152 | # XXX You do not need to understand the next function! | |
146 | # This should probably be moved out of profile |
|
153 | # This should probably be moved out of profile | |
147 |
|
154 | |||
148 | def extend_shell_behavior(ip): |
|
155 | def extend_shell_behavior(ip): | |
149 |
|
156 | |||
150 | # Instead of making signature a global variable tie it to IPSHELL. |
|
157 | # Instead of making signature a global variable tie it to IPSHELL. | |
151 | # In future if it is required to distinguish between different |
|
158 | # In future if it is required to distinguish between different | |
152 | # shells we can assign a signature per shell basis |
|
159 | # shells we can assign a signature per shell basis | |
153 | ip.IP.__sig__ = 0xa005 |
|
160 | ip.IP.__sig__ = 0xa005 | |
154 | # mark the IPSHELL with this signature |
|
161 | # mark the IPSHELL with this signature | |
155 | ip.IP.user_ns['__builtins__'].__dict__['__sig__'] = ip.IP.__sig__ |
|
162 | ip.IP.user_ns['__builtins__'].__dict__['__sig__'] = ip.IP.__sig__ | |
156 |
|
163 | |||
157 | from IPython.Itpl import ItplNS |
|
164 | from IPython.Itpl import ItplNS | |
158 | from IPython.genutils import shell |
|
165 | from IPython.genutils import shell | |
159 | # utility to expand user variables via Itpl |
|
166 | # utility to expand user variables via Itpl | |
160 | # xxx do something sensible with depth? |
|
167 | # xxx do something sensible with depth? | |
161 | ip.IP.var_expand = lambda cmd, lvars=None, depth=2: \ |
|
168 | ip.IP.var_expand = lambda cmd, lvars=None, depth=2: \ | |
162 | str(ItplNS(cmd, ip.IP.user_ns, get_locals())) |
|
169 | str(ItplNS(cmd, ip.IP.user_ns, get_locals())) | |
163 |
|
170 | |||
164 | def get_locals(): |
|
171 | def get_locals(): | |
165 | """ Substituting a variable through Itpl deep inside the IPSHELL stack |
|
172 | """ Substituting a variable through Itpl deep inside the IPSHELL stack | |
166 | requires the knowledge of all the variables in scope upto the last |
|
173 | requires the knowledge of all the variables in scope upto the last | |
167 | IPSHELL frame. This routine simply merges all the local variables |
|
174 | IPSHELL frame. This routine simply merges all the local variables | |
168 | on the IPSHELL stack without worrying about their scope rules |
|
175 | on the IPSHELL stack without worrying about their scope rules | |
169 | """ |
|
176 | """ | |
170 | import sys |
|
177 | import sys | |
171 | # note lambda expression constitues a function call |
|
178 | # note lambda expression constitues a function call | |
172 | # hence fno should be incremented by one |
|
179 | # hence fno should be incremented by one | |
173 | getsig = lambda fno: sys._getframe(fno+1).f_globals \ |
|
180 | getsig = lambda fno: sys._getframe(fno+1).f_globals \ | |
174 | ['__builtins__'].__dict__['__sig__'] |
|
181 | ['__builtins__'].__dict__['__sig__'] | |
175 | getlvars = lambda fno: sys._getframe(fno+1).f_locals |
|
182 | getlvars = lambda fno: sys._getframe(fno+1).f_locals | |
176 | # trackback until we enter the IPSHELL |
|
183 | # trackback until we enter the IPSHELL | |
177 | frame_no = 1 |
|
184 | frame_no = 1 | |
178 | sig = ip.IP.__sig__ |
|
185 | sig = ip.IP.__sig__ | |
179 | fsig = ~sig |
|
186 | fsig = ~sig | |
180 | while fsig != sig : |
|
187 | while fsig != sig : | |
181 | try: |
|
188 | try: | |
182 | fsig = getsig(frame_no) |
|
189 | fsig = getsig(frame_no) | |
183 | except (AttributeError, KeyError): |
|
190 | except (AttributeError, KeyError): | |
184 | frame_no += 1 |
|
191 | frame_no += 1 | |
185 | except ValueError: |
|
192 | except ValueError: | |
186 | # stack is depleted |
|
193 | # stack is depleted | |
187 | # call did not originate from IPSHELL |
|
194 | # call did not originate from IPSHELL | |
188 | return {} |
|
195 | return {} | |
189 | first_frame = frame_no |
|
196 | first_frame = frame_no | |
190 | # walk further back until we exit from IPSHELL or deplete stack |
|
197 | # walk further back until we exit from IPSHELL or deplete stack | |
191 | try: |
|
198 | try: | |
192 | while(sig == getsig(frame_no+1)): |
|
199 | while(sig == getsig(frame_no+1)): | |
193 | frame_no += 1 |
|
200 | frame_no += 1 | |
194 | except (AttributeError, KeyError, ValueError): |
|
201 | except (AttributeError, KeyError, ValueError): | |
195 | pass |
|
202 | pass | |
196 | # merge the locals from top down hence overriding |
|
203 | # merge the locals from top down hence overriding | |
197 | # any re-definitions of variables, functions etc. |
|
204 | # any re-definitions of variables, functions etc. | |
198 | lvars = {} |
|
205 | lvars = {} | |
199 | for fno in range(frame_no, first_frame-1, -1): |
|
206 | for fno in range(frame_no, first_frame-1, -1): | |
200 | lvars.update(getlvars(fno)) |
|
207 | lvars.update(getlvars(fno)) | |
201 | #print '\n'*5, first_frame, frame_no, '\n', lvars, '\n'*5 #dbg |
|
208 | #print '\n'*5, first_frame, frame_no, '\n', lvars, '\n'*5 #dbg | |
202 | return lvars |
|
209 | return lvars | |
203 |
|
210 | |||
204 | def _runlines(lines): |
|
211 | def _runlines(lines): | |
205 | """Run a string of one or more lines of source. |
|
212 | """Run a string of one or more lines of source. | |
206 |
|
213 | |||
207 | This method is capable of running a string containing multiple source |
|
214 | This method is capable of running a string containing multiple source | |
208 | lines, as if they had been entered at the IPython prompt. Since it |
|
215 | lines, as if they had been entered at the IPython prompt. Since it | |
209 | exposes IPython's processing machinery, the given strings can contain |
|
216 | exposes IPython's processing machinery, the given strings can contain | |
210 | magic calls (%magic), special shell access (!cmd), etc.""" |
|
217 | magic calls (%magic), special shell access (!cmd), etc.""" | |
211 |
|
218 | |||
212 | # We must start with a clean buffer, in case this is run from an |
|
219 | # We must start with a clean buffer, in case this is run from an | |
213 | # interactive IPython session (via a magic, for example). |
|
220 | # interactive IPython session (via a magic, for example). | |
214 | ip.IP.resetbuffer() |
|
221 | ip.IP.resetbuffer() | |
215 | lines = lines.split('\n') |
|
222 | lines = lines.split('\n') | |
216 | more = 0 |
|
223 | more = 0 | |
217 | command = '' |
|
224 | command = '' | |
218 | for line in lines: |
|
225 | for line in lines: | |
219 | # skip blank lines so we don't mess up the prompt counter, but do |
|
226 | # skip blank lines so we don't mess up the prompt counter, but do | |
220 | # NOT skip even a blank line if we are in a code block (more is |
|
227 | # NOT skip even a blank line if we are in a code block (more is | |
221 | # true) |
|
228 | # true) | |
222 | # if command is not empty trim the line |
|
229 | # if command is not empty trim the line | |
223 | if command != '' : |
|
230 | if command != '' : | |
224 | line = line.strip() |
|
231 | line = line.strip() | |
225 | # add the broken line to the command |
|
232 | # add the broken line to the command | |
226 | if line and line[-1] == '\\' : |
|
233 | if line and line[-1] == '\\' : | |
227 | command += line[0:-1] + ' ' |
|
234 | command += line[0:-1] + ' ' | |
228 | more = True |
|
235 | more = True | |
229 | continue |
|
236 | continue | |
230 | else : |
|
237 | else : | |
231 | # add the last (current) line to the command |
|
238 | # add the last (current) line to the command | |
232 | command += line |
|
239 | command += line | |
233 | if command or more: |
|
240 | if command or more: | |
234 | # push to raw history, so hist line numbers stay in sync |
|
241 | # push to raw history, so hist line numbers stay in sync | |
235 | ip.IP.input_hist_raw.append("# " + command + "\n") |
|
242 | ip.IP.input_hist_raw.append("# " + command + "\n") | |
236 |
|
243 | |||
237 | more = ip.IP.push(ip.IP.prefilter(command,more)) |
|
244 | more = ip.IP.push(ip.IP.prefilter(command,more)) | |
238 | command = '' |
|
245 | command = '' | |
239 | # IPython's runsource returns None if there was an error |
|
246 | # IPython's runsource returns None if there was an error | |
240 | # compiling the code. This allows us to stop processing right |
|
247 | # compiling the code. This allows us to stop processing right | |
241 | # away, so the user gets the error message at the right place. |
|
248 | # away, so the user gets the error message at the right place. | |
242 | if more is None: |
|
249 | if more is None: | |
243 | break |
|
250 | break | |
244 | # final newline in case the input didn't have it, so that the code |
|
251 | # final newline in case the input didn't have it, so that the code | |
245 | # actually does get executed |
|
252 | # actually does get executed | |
246 | if more: |
|
253 | if more: | |
247 | ip.IP.push('\n') |
|
254 | ip.IP.push('\n') | |
248 |
|
255 | |||
249 | ip.IP.runlines = _runlines |
|
256 | ip.IP.runlines = _runlines | |
250 |
|
257 | |||
251 | main() |
|
258 | main() |
@@ -1,107 +1,116 b'' | |||||
1 | """ User configuration file for IPython |
|
1 | """ User configuration file for IPython | |
2 |
|
2 | |||
3 | This is a more flexible and safe way to configure ipython than *rc files |
|
3 | This is a more flexible and safe way to configure ipython than *rc files | |
4 | (ipythonrc, ipythonrc-pysh etc.) |
|
4 | (ipythonrc, ipythonrc-pysh etc.) | |
5 |
|
5 | |||
6 | This file is always imported on ipython startup. You can import the |
|
6 | This file is always imported on ipython startup. You can import the | |
7 | ipython extensions you need here (see IPython/Extensions directory). |
|
7 | ipython extensions you need here (see IPython/Extensions directory). | |
8 |
|
8 | |||
9 | Feel free to edit this file to customize your ipython experience. |
|
9 | Feel free to edit this file to customize your ipython experience. | |
10 |
|
10 | |||
11 | Note that as such this file does nothing, for backwards compatibility. |
|
11 | Note that as such this file does nothing, for backwards compatibility. | |
12 | Consult e.g. file 'ipy_profile_sh.py' for an example of the things |
|
12 | Consult e.g. file 'ipy_profile_sh.py' for an example of the things | |
13 | you can do here. |
|
13 | you can do here. | |
14 |
|
14 | |||
15 | See http://ipython.scipy.org/moin/IpythonExtensionApi for detailed |
|
15 | See http://ipython.scipy.org/moin/IpythonExtensionApi for detailed | |
16 | description on what you could do here. |
|
16 | description on what you could do here. | |
17 | """ |
|
17 | """ | |
18 |
|
18 | |||
19 | # Most of your config files and extensions will probably start with this import |
|
19 | # Most of your config files and extensions will probably start with this import | |
20 |
|
20 | |||
21 | import IPython.ipapi |
|
21 | import IPython.ipapi | |
22 | ip = IPython.ipapi.get() |
|
22 | ip = IPython.ipapi.get() | |
23 |
|
23 | |||
24 | # You probably want to uncomment this if you did %upgrade -nolegacy |
|
24 | # You probably want to uncomment this if you did %upgrade -nolegacy | |
25 | # import ipy_defaults |
|
25 | # import ipy_defaults | |
26 |
|
26 | |||
27 | import os |
|
27 | import os | |
28 |
|
28 | |||
29 | def main(): |
|
29 | def main(): | |
30 |
|
30 | |||
31 | # uncomment if you want to get ipython -p sh behaviour |
|
31 | # uncomment if you want to get ipython -p sh behaviour | |
32 | # without having to use command line switches |
|
32 | # without having to use command line switches | |
33 | # import ipy_profile_sh |
|
33 | # import ipy_profile_sh | |
34 |
|
34 | |||
35 | # Configure your favourite editor? |
|
35 | # Configure your favourite editor? | |
36 | # Good idea e.g. for %edit os.path.isfile |
|
36 | # Good idea e.g. for %edit os.path.isfile | |
37 |
|
37 | |||
38 | #import ipy_editors |
|
38 | #import ipy_editors | |
39 |
|
39 | |||
40 | # Choose one of these: |
|
40 | # Choose one of these: | |
41 |
|
41 | |||
42 | #ipy_editors.scite() |
|
42 | #ipy_editors.scite() | |
43 | #ipy_editors.scite('c:/opt/scite/scite.exe') |
|
43 | #ipy_editors.scite('c:/opt/scite/scite.exe') | |
44 | #ipy_editors.komodo() |
|
44 | #ipy_editors.komodo() | |
45 | #ipy_editors.idle() |
|
45 | #ipy_editors.idle() | |
46 | # ... or many others, try 'ipy_editors??' after import to see them |
|
46 | # ... or many others, try 'ipy_editors??' after import to see them | |
47 |
|
47 | |||
48 | # Or roll your own: |
|
48 | # Or roll your own: | |
49 | #ipy_editors.install_editor("c:/opt/jed +$line $file") |
|
49 | #ipy_editors.install_editor("c:/opt/jed +$line $file") | |
50 |
|
50 | |||
51 |
|
51 | |||
52 | o = ip.options |
|
52 | o = ip.options | |
53 | # An example on how to set options |
|
53 | # An example on how to set options | |
54 | #o.autocall = 1 |
|
54 | #o.autocall = 1 | |
55 | o.system_verbose = 0 |
|
55 | o.system_verbose = 0 | |
56 |
|
56 | |||
57 | #import_all("os sys") |
|
57 | #import_all("os sys") | |
58 | #execf('~/_ipython/ns.py') |
|
58 | #execf('~/_ipython/ns.py') | |
59 |
|
59 | |||
60 |
|
60 | |||
61 | # -- prompt |
|
61 | # -- prompt | |
62 | # A different, more compact set of prompts from the default ones, that |
|
62 | # A different, more compact set of prompts from the default ones, that | |
63 | # always show your current location in the filesystem: |
|
63 | # always show your current location in the filesystem: | |
64 |
|
64 | |||
65 | #o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>' |
|
65 | #o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>' | |
66 | #o.prompt_in2 = r'.\D: ' |
|
66 | #o.prompt_in2 = r'.\D: ' | |
67 | #o.prompt_out = r'[\#] ' |
|
67 | #o.prompt_out = r'[\#] ' | |
68 |
|
68 | |||
69 | # Try one of these color settings if you can't read the text easily |
|
69 | # Try one of these color settings if you can't read the text easily | |
70 | # autoexec is a list of IPython commands to execute on startup |
|
70 | # autoexec is a list of IPython commands to execute on startup | |
71 | #o.autoexec.append('%colors LightBG') |
|
71 | #o.autoexec.append('%colors LightBG') | |
72 | #o.autoexec.append('%colors NoColor') |
|
72 | #o.autoexec.append('%colors NoColor') | |
73 | #o.autoexec.append('%colors Linux') |
|
73 | #o.autoexec.append('%colors Linux') | |
74 |
|
74 | |||
75 | # for sane integer division that converts to float (1/2 == 0.5) |
|
75 | # for sane integer division that converts to float (1/2 == 0.5) | |
76 | #o.autoexec.append('from __future__ import division') |
|
76 | #o.autoexec.append('from __future__ import division') | |
77 |
|
77 | |||
78 | # For %tasks and %kill |
|
78 | # For %tasks and %kill | |
79 | #import jobctrl |
|
79 | #import jobctrl | |
80 |
|
80 | |||
81 | # For autoreloading of modules (%autoreload, %aimport) |
|
81 | # For autoreloading of modules (%autoreload, %aimport) | |
82 | #import ipy_autoreload |
|
82 | #import ipy_autoreload | |
83 |
|
83 | |||
84 | # For winpdb support (%wdb) |
|
84 | # For winpdb support (%wdb) | |
85 | #import ipy_winpdb |
|
85 | #import ipy_winpdb | |
86 |
|
86 | |||
87 | # For bzr completer, requires bzrlib (the python installation of bzr) |
|
87 | # For bzr completer, requires bzrlib (the python installation of bzr) | |
88 | #ip.load('ipy_bzr') |
|
88 | #ip.load('ipy_bzr') | |
89 |
|
89 | |||
90 | # Tab completer that is not quite so picky (i.e. |
|
90 | # Tab completer that is not quite so picky (i.e. | |
91 | # "foo".<TAB> and str(2).<TAB> will work). Complete |
|
91 | # "foo".<TAB> and str(2).<TAB> will work). Complete | |
92 | # at your own risk! |
|
92 | # at your own risk! | |
93 | #import ipy_greedycompleter |
|
93 | #import ipy_greedycompleter | |
94 |
|
94 | |||
|
95 | # If you are on Linux, you may be annoyed by | |||
|
96 | # "Display all N possibilities? (y or n)" on tab completion, | |||
|
97 | # as well as the paging through "more". Uncomment the following | |||
|
98 | # lines to disable that behaviour | |||
|
99 | #import readline | |||
|
100 | #readline.parse_and_bind('set completion-query-items 1000') | |||
|
101 | #readline.parse_and_bind('set page-completions no') | |||
|
102 | ||||
|
103 | ||||
95 |
|
104 | |||
96 |
|
105 | |||
97 | # some config helper functions you can use |
|
106 | # some config helper functions you can use | |
98 | def import_all(modules): |
|
107 | def import_all(modules): | |
99 | """ Usage: import_all("os sys") """ |
|
108 | """ Usage: import_all("os sys") """ | |
100 | for m in modules.split(): |
|
109 | for m in modules.split(): | |
101 | ip.ex("from %s import *" % m) |
|
110 | ip.ex("from %s import *" % m) | |
102 |
|
111 | |||
103 | def execf(fname): |
|
112 | def execf(fname): | |
104 | """ Execute a file in user namespace """ |
|
113 | """ Execute a file in user namespace """ | |
105 | ip.ex('execfile("%s")' % os.path.expanduser(fname)) |
|
114 | ip.ex('execfile("%s")' % os.path.expanduser(fname)) | |
106 |
|
115 | |||
107 | main() |
|
116 | main() |
@@ -1,161 +1,162 b'' | |||||
1 | .. _changes: |
|
1 | .. _changes: | |
2 |
|
2 | |||
3 | ========== |
|
3 | ========== | |
4 | What's new |
|
4 | What's new | |
5 | ========== |
|
5 | ========== | |
6 |
|
6 | |||
7 | .. contents:: |
|
7 | .. contents:: | |
8 |
|
8 | |||
9 | Release 0.9 |
|
9 | Release 0.9 | |
10 | =========== |
|
10 | =========== | |
11 |
|
11 | |||
12 | New features |
|
12 | New features | |
13 | ------------ |
|
13 | ------------ | |
14 |
|
14 | |||
15 | * All of the parallel computing capabilities from `ipython1-dev` have been merged into |
|
15 | * All of the parallel computing capabilities from `ipython1-dev` have been merged into | |
16 | IPython proper. This resulted in the following new subpackages: |
|
16 | IPython proper. This resulted in the following new subpackages: | |
17 | :mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:`IPython.config`, |
|
17 | :mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:`IPython.config`, | |
18 | :mod:`IPython.tools` and :mod:`IPython.testing`. |
|
18 | :mod:`IPython.tools` and :mod:`IPython.testing`. | |
19 | * As part of merging in the `ipython1-dev` stuff, the `setup.py` script and friends |
|
19 | * As part of merging in the `ipython1-dev` stuff, the `setup.py` script and friends | |
20 | have been completely refactored. Now we are checking for dependencies using |
|
20 | have been completely refactored. Now we are checking for dependencies using | |
21 | the approach that matplotlib uses. |
|
21 | the approach that matplotlib uses. | |
22 | * The documentation has been completely reorganized to accept the documentation |
|
22 | * The documentation has been completely reorganized to accept the documentation | |
23 | from `ipython1-dev`. |
|
23 | from `ipython1-dev`. | |
24 | * We have switched to using Foolscap for all of our network protocols in |
|
24 | * We have switched to using Foolscap for all of our network protocols in | |
25 | :mod:`IPython.kernel`. This gives us secure connections that are both encrypted |
|
25 | :mod:`IPython.kernel`. This gives us secure connections that are both encrypted | |
26 | and authenticated. |
|
26 | and authenticated. | |
27 | * We have a brand new `COPYING.txt` files that describes the IPython license |
|
27 | * We have a brand new `COPYING.txt` files that describes the IPython license | |
28 | and copyright. The biggest change is that we are putting "The IPython |
|
28 | and copyright. The biggest change is that we are putting "The IPython | |
29 | Development Team" as the copyright holder. We give more details about exactly |
|
29 | Development Team" as the copyright holder. We give more details about exactly | |
30 | what this means in this file. All developer should read this and use the new |
|
30 | what this means in this file. All developer should read this and use the new | |
31 | banner in all IPython source code files. |
|
31 | banner in all IPython source code files. | |
|
32 | * sh profile: ./foo runs foo as system command, no need to do !./foo anymore | |||
32 |
|
33 | |||
33 | Bug fixes |
|
34 | Bug fixes | |
34 | --------- |
|
35 | --------- | |
35 |
|
36 | |||
36 | * A few subpackages has missing `__init__.py` files. |
|
37 | * A few subpackages has missing `__init__.py` files. | |
37 | * The documentation is only created is Sphinx is found. Previously, the `setup.py` |
|
38 | * The documentation is only created is Sphinx is found. Previously, the `setup.py` | |
38 | script would fail if it was missing. |
|
39 | script would fail if it was missing. | |
39 |
|
40 | |||
40 | Backwards incompatible changes |
|
41 | Backwards incompatible changes | |
41 | ------------------------------ |
|
42 | ------------------------------ | |
42 |
|
43 | |||
43 | * IPython has a larger set of dependencies if you want all of its capabilities. |
|
44 | * IPython has a larger set of dependencies if you want all of its capabilities. | |
44 | See the `setup.py` script for details. |
|
45 | See the `setup.py` script for details. | |
45 | * The constructors for :class:`IPython.kernel.client.MultiEngineClient` and |
|
46 | * The constructors for :class:`IPython.kernel.client.MultiEngineClient` and | |
46 | :class:`IPython.kernel.client.TaskClient` no longer take the (ip,port) tuple. |
|
47 | :class:`IPython.kernel.client.TaskClient` no longer take the (ip,port) tuple. | |
47 | Instead they take the filename of a file that contains the FURL for that |
|
48 | Instead they take the filename of a file that contains the FURL for that | |
48 | client. If the FURL file is in your IPYTHONDIR, it will be found automatically |
|
49 | client. If the FURL file is in your IPYTHONDIR, it will be found automatically | |
49 | and the constructor can be left empty. |
|
50 | and the constructor can be left empty. | |
50 | * The asynchronous clients in :mod:`IPython.kernel.asyncclient` are now created |
|
51 | * The asynchronous clients in :mod:`IPython.kernel.asyncclient` are now created | |
51 | using the factory functions :func:`get_multiengine_client` and |
|
52 | using the factory functions :func:`get_multiengine_client` and | |
52 | :func:`get_task_client`. These return a `Deferred` to the actual client. |
|
53 | :func:`get_task_client`. These return a `Deferred` to the actual client. | |
53 | * The command line options to `ipcontroller` and `ipengine` have changed to |
|
54 | * The command line options to `ipcontroller` and `ipengine` have changed to | |
54 | reflect the new Foolscap network protocol and the FURL files. Please see the |
|
55 | reflect the new Foolscap network protocol and the FURL files. Please see the | |
55 | help for these scripts for details. |
|
56 | help for these scripts for details. | |
56 | * The configuration files for the kernel have changed because of the Foolscap stuff. |
|
57 | * The configuration files for the kernel have changed because of the Foolscap stuff. | |
57 | If you were using custom config files before, you should delete them and regenerate |
|
58 | If you were using custom config files before, you should delete them and regenerate | |
58 | new ones. |
|
59 | new ones. | |
59 |
|
60 | |||
60 | Changes merged in from IPython1 |
|
61 | Changes merged in from IPython1 | |
61 | ------------------------------- |
|
62 | ------------------------------- | |
62 |
|
63 | |||
63 | New features |
|
64 | New features | |
64 | ............ |
|
65 | ............ | |
65 |
|
66 | |||
66 | * Much improved ``setup.py`` and ``setupegg.py`` scripts. Because Twisted |
|
67 | * Much improved ``setup.py`` and ``setupegg.py`` scripts. Because Twisted | |
67 | and zope.interface are now easy installable, we can declare them as dependencies |
|
68 | and zope.interface are now easy installable, we can declare them as dependencies | |
68 | in our setupegg.py script. |
|
69 | in our setupegg.py script. | |
69 | * IPython is now compatible with Twisted 2.5.0 and 8.x. |
|
70 | * IPython is now compatible with Twisted 2.5.0 and 8.x. | |
70 | * Added a new example of how to use :mod:`ipython1.kernel.asynclient`. |
|
71 | * Added a new example of how to use :mod:`ipython1.kernel.asynclient`. | |
71 | * Initial draft of a process daemon in :mod:`ipython1.daemon`. This has not |
|
72 | * Initial draft of a process daemon in :mod:`ipython1.daemon`. This has not | |
72 | been merged into IPython and is still in `ipython1-dev`. |
|
73 | been merged into IPython and is still in `ipython1-dev`. | |
73 | * The ``TaskController`` now has methods for getting the queue status. |
|
74 | * The ``TaskController`` now has methods for getting the queue status. | |
74 | * The ``TaskResult`` objects not have information about how long the task |
|
75 | * The ``TaskResult`` objects not have information about how long the task | |
75 | took to run. |
|
76 | took to run. | |
76 | * We are attaching additional attributes to exceptions ``(_ipython_*)`` that |
|
77 | * We are attaching additional attributes to exceptions ``(_ipython_*)`` that | |
77 | we use to carry additional info around. |
|
78 | we use to carry additional info around. | |
78 | * New top-level module :mod:`asyncclient` that has asynchronous versions (that |
|
79 | * New top-level module :mod:`asyncclient` that has asynchronous versions (that | |
79 | return deferreds) of the client classes. This is designed to users who want |
|
80 | return deferreds) of the client classes. This is designed to users who want | |
80 | to run their own Twisted reactor |
|
81 | to run their own Twisted reactor | |
81 | * All the clients in :mod:`client` are now based on Twisted. This is done by |
|
82 | * All the clients in :mod:`client` are now based on Twisted. This is done by | |
82 | running the Twisted reactor in a separate thread and using the |
|
83 | running the Twisted reactor in a separate thread and using the | |
83 | :func:`blockingCallFromThread` function that is in recent versions of Twisted. |
|
84 | :func:`blockingCallFromThread` function that is in recent versions of Twisted. | |
84 | * Functions can now be pushed/pulled to/from engines using |
|
85 | * Functions can now be pushed/pulled to/from engines using | |
85 | :meth:`MultiEngineClient.push_function` and :meth:`MultiEngineClient.pull_function`. |
|
86 | :meth:`MultiEngineClient.push_function` and :meth:`MultiEngineClient.pull_function`. | |
86 | * Gather/scatter are now implemented in the client to reduce the work load |
|
87 | * Gather/scatter are now implemented in the client to reduce the work load | |
87 | of the controller and improve performance. |
|
88 | of the controller and improve performance. | |
88 | * Complete rewrite of the IPython docuementation. All of the documentation |
|
89 | * Complete rewrite of the IPython docuementation. All of the documentation | |
89 | from the IPython website has been moved into docs/source as restructured |
|
90 | from the IPython website has been moved into docs/source as restructured | |
90 | text documents. PDF and HTML documentation are being generated using |
|
91 | text documents. PDF and HTML documentation are being generated using | |
91 | Sphinx. |
|
92 | Sphinx. | |
92 | * New developer oriented documentation: development guidelines and roadmap. |
|
93 | * New developer oriented documentation: development guidelines and roadmap. | |
93 | * Traditional ``ChangeLog`` has been changed to a more useful ``changes.txt`` file |
|
94 | * Traditional ``ChangeLog`` has been changed to a more useful ``changes.txt`` file | |
94 | that is organized by release and is meant to provide something more relevant |
|
95 | that is organized by release and is meant to provide something more relevant | |
95 | for users. |
|
96 | for users. | |
96 |
|
97 | |||
97 | Bug fixes |
|
98 | Bug fixes | |
98 | ......... |
|
99 | ......... | |
99 |
|
100 | |||
100 | * Created a proper ``MANIFEST.in`` file to create source distributions. |
|
101 | * Created a proper ``MANIFEST.in`` file to create source distributions. | |
101 | * Fixed a bug in the ``MultiEngine`` interface. Previously, multi-engine |
|
102 | * Fixed a bug in the ``MultiEngine`` interface. Previously, multi-engine | |
102 | actions were being collected with a :class:`DeferredList` with |
|
103 | actions were being collected with a :class:`DeferredList` with | |
103 | ``fireononeerrback=1``. This meant that methods were returning |
|
104 | ``fireononeerrback=1``. This meant that methods were returning | |
104 | before all engines had given their results. This was causing extremely odd |
|
105 | before all engines had given their results. This was causing extremely odd | |
105 | bugs in certain cases. To fix this problem, we have 1) set |
|
106 | bugs in certain cases. To fix this problem, we have 1) set | |
106 | ``fireononeerrback=0`` to make sure all results (or exceptions) are in |
|
107 | ``fireononeerrback=0`` to make sure all results (or exceptions) are in | |
107 | before returning and 2) introduced a :exc:`CompositeError` exception |
|
108 | before returning and 2) introduced a :exc:`CompositeError` exception | |
108 | that wraps all of the engine exceptions. This is a huge change as it means |
|
109 | that wraps all of the engine exceptions. This is a huge change as it means | |
109 | that users will have to catch :exc:`CompositeError` rather than the actual |
|
110 | that users will have to catch :exc:`CompositeError` rather than the actual | |
110 | exception. |
|
111 | exception. | |
111 |
|
112 | |||
112 | Backwards incompatible changes |
|
113 | Backwards incompatible changes | |
113 | .............................. |
|
114 | .............................. | |
114 |
|
115 | |||
115 | * All names have been renamed to conform to the lowercase_with_underscore |
|
116 | * All names have been renamed to conform to the lowercase_with_underscore | |
116 | convention. This will require users to change references to all names like |
|
117 | convention. This will require users to change references to all names like | |
117 | ``queueStatus`` to ``queue_status``. |
|
118 | ``queueStatus`` to ``queue_status``. | |
118 | * Previously, methods like :meth:`MultiEngineClient.push` and |
|
119 | * Previously, methods like :meth:`MultiEngineClient.push` and | |
119 | :meth:`MultiEngineClient.push` used ``*args`` and ``**kwargs``. This was |
|
120 | :meth:`MultiEngineClient.push` used ``*args`` and ``**kwargs``. This was | |
120 | becoming a problem as we weren't able to introduce new keyword arguments into |
|
121 | becoming a problem as we weren't able to introduce new keyword arguments into | |
121 | the API. Now these methods simple take a dict or sequence. This has also allowed |
|
122 | the API. Now these methods simple take a dict or sequence. This has also allowed | |
122 | us to get rid of the ``*All`` methods like :meth:`pushAll` and :meth:`pullAll`. |
|
123 | us to get rid of the ``*All`` methods like :meth:`pushAll` and :meth:`pullAll`. | |
123 | These things are now handled with the ``targets`` keyword argument that defaults |
|
124 | These things are now handled with the ``targets`` keyword argument that defaults | |
124 | to ``'all'``. |
|
125 | to ``'all'``. | |
125 | * The :attr:`MultiEngineClient.magicTargets` has been renamed to |
|
126 | * The :attr:`MultiEngineClient.magicTargets` has been renamed to | |
126 | :attr:`MultiEngineClient.targets`. |
|
127 | :attr:`MultiEngineClient.targets`. | |
127 | * All methods in the MultiEngine interface now accept the optional keyword argument |
|
128 | * All methods in the MultiEngine interface now accept the optional keyword argument | |
128 | ``block``. |
|
129 | ``block``. | |
129 | * Renamed :class:`RemoteController` to :class:`MultiEngineClient` and |
|
130 | * Renamed :class:`RemoteController` to :class:`MultiEngineClient` and | |
130 | :class:`TaskController` to :class:`TaskClient`. |
|
131 | :class:`TaskController` to :class:`TaskClient`. | |
131 | * Renamed the top-level module from :mod:`api` to :mod:`client`. |
|
132 | * Renamed the top-level module from :mod:`api` to :mod:`client`. | |
132 | * Most methods in the multiengine interface now raise a :exc:`CompositeError` exception |
|
133 | * Most methods in the multiengine interface now raise a :exc:`CompositeError` exception | |
133 | that wraps the user's exceptions, rather than just raising the raw user's exception. |
|
134 | that wraps the user's exceptions, rather than just raising the raw user's exception. | |
134 | * Changed the ``setupNS`` and ``resultNames`` in the ``Task`` class to ``push`` |
|
135 | * Changed the ``setupNS`` and ``resultNames`` in the ``Task`` class to ``push`` | |
135 | and ``pull``. |
|
136 | and ``pull``. | |
136 |
|
137 | |||
137 | Release 0.8.4 |
|
138 | Release 0.8.4 | |
138 | ============= |
|
139 | ============= | |
139 |
|
140 | |||
140 | Someone needs to describe what went into 0.8.4. |
|
141 | Someone needs to describe what went into 0.8.4. | |
141 |
|
142 | |||
142 | Release 0.8.2 |
|
143 | Release 0.8.2 | |
143 | ============= |
|
144 | ============= | |
144 |
|
145 | |||
145 | * %pushd/%popd behave differently; now "pushd /foo" pushes CURRENT directory |
|
146 | * %pushd/%popd behave differently; now "pushd /foo" pushes CURRENT directory | |
146 | and jumps to /foo. The current behaviour is closer to the documented |
|
147 | and jumps to /foo. The current behaviour is closer to the documented | |
147 | behaviour, and should not trip anyone. |
|
148 | behaviour, and should not trip anyone. | |
148 |
|
149 | |||
149 | Release 0.8.3 |
|
150 | Release 0.8.3 | |
150 | ============= |
|
151 | ============= | |
151 |
|
152 | |||
152 | * pydb is now disabled by default (due to %run -d problems). You can enable |
|
153 | * pydb is now disabled by default (due to %run -d problems). You can enable | |
153 | it by passing -pydb command line argument to IPython. Note that setting |
|
154 | it by passing -pydb command line argument to IPython. Note that setting | |
154 | it in config file won't work. |
|
155 | it in config file won't work. | |
155 |
|
156 | |||
156 | Older releases |
|
157 | Older releases | |
157 | ============== |
|
158 | ============== | |
158 |
|
159 | |||
159 | Changes in earlier releases of IPython are described in the older file ``ChangeLog``. |
|
160 | Changes in earlier releases of IPython are described in the older file ``ChangeLog``. | |
160 | Please refer to this document for details. |
|
161 | Please refer to this document for details. | |
161 |
|
162 |
General Comments 0
You need to be logged in to leave comments.
Login now