##// END OF EJS Templates
Remove shell hook and system_verbose magic....
Fernando Perez -
Show More
@@ -120,10 +120,6 b' c = get_config()'
120 # c.InteractiveShell.separate_out = ''
120 # c.InteractiveShell.separate_out = ''
121 # c.InteractiveShell.separate_out2 = ''
121 # c.InteractiveShell.separate_out2 = ''
122
122
123 # c.InteractiveShell.system_header = "IPython system call: "
124
125 # c.InteractiveShell.system_verbose = True
126
127 # c.TerminalInteractiveShell.term_title = False
123 # c.TerminalInteractiveShell.term_title = False
128
124
129 # c.InteractiveShell.wildcards_case_sensitive = True
125 # c.InteractiveShell.wildcards_case_sensitive = True
@@ -46,16 +46,14 b' import sys'
46
46
47 from IPython.core.error import TryNext
47 from IPython.core.error import TryNext
48 import IPython.utils.io
48 import IPython.utils.io
49 from IPython.utils.process import shell
50
49
51 # List here all the default hooks. For now it's just the editor functions
50 # List here all the default hooks. For now it's just the editor functions
52 # but over time we'll move here all the public API for user-accessible things.
51 # but over time we'll move here all the public API for user-accessible things.
53
52
54 __all__ = ['editor', 'fix_error_editor', 'synchronize_with_editor',
53 __all__ = ['editor', 'fix_error_editor', 'synchronize_with_editor',
55 'input_prefilter', 'shutdown_hook', 'late_startup_hook',
54 'input_prefilter', 'shutdown_hook', 'late_startup_hook',
56 'generate_prompt','shell_hook',
55 'generate_prompt', 'show_in_pager','pre_prompt_hook',
57 'show_in_pager','pre_prompt_hook', 'pre_runcode_hook',
56 'pre_runcode_hook', 'clipboard_get']
58 'clipboard_get']
59
57
60 def editor(self,filename, linenum=None):
58 def editor(self,filename, linenum=None):
61 """Open the default editor at the given filename and linenumber.
59 """Open the default editor at the given filename and linenumber.
@@ -220,12 +218,6 b' def generate_prompt(self, is_continuation):'
220 return str(self.displayhook.prompt1)
218 return str(self.displayhook.prompt1)
221
219
222
220
223 def shell_hook(self,cmd):
224 """ Run system/shell command a'la os.system() """
225
226 shell(cmd, header=self.system_header, verbose=self.system_verbose)
227
228
229 def show_in_pager(self,s):
221 def show_in_pager(self,s):
230 """ Run a string through pager """
222 """ Run a string through pager """
231 # raising TryNext here will use the default paging functionality
223 # raising TryNext here will use the default paging functionality
@@ -57,7 +57,7 b' from IPython.utils.doctestreload import doctest_reload'
57 from IPython.utils.io import ask_yes_no, rprint
57 from IPython.utils.io import ask_yes_no, rprint
58 from IPython.utils.ipstruct import Struct
58 from IPython.utils.ipstruct import Struct
59 from IPython.utils.path import get_home_dir, get_ipython_dir, HomeDirError
59 from IPython.utils.path import get_home_dir, get_ipython_dir, HomeDirError
60 from IPython.utils.process import getoutput, getoutputerror
60 from IPython.utils.process import system, getoutput, getoutputerror
61 from IPython.utils.strdispatch import StrDispatch
61 from IPython.utils.strdispatch import StrDispatch
62 from IPython.utils.syspathcontext import prepended_to_syspath
62 from IPython.utils.syspathcontext import prepended_to_syspath
63 from IPython.utils.text import num_ini_spaces
63 from IPython.utils.text import num_ini_spaces
@@ -197,8 +197,6 b' class InteractiveShell(Configurable, Magic):'
197 separate_in = SeparateStr('\n', config=True)
197 separate_in = SeparateStr('\n', config=True)
198 separate_out = SeparateStr('', config=True)
198 separate_out = SeparateStr('', config=True)
199 separate_out2 = SeparateStr('', config=True)
199 separate_out2 = SeparateStr('', config=True)
200 system_header = Str('IPython system call: ', config=True)
201 system_verbose = CBool(False, config=True)
202 wildcards_case_sensitive = CBool(True, config=True)
200 wildcards_case_sensitive = CBool(True, config=True)
203 xmode = CaselessStrEnum(('Context','Plain', 'Verbose'),
201 xmode = CaselessStrEnum(('Context','Plain', 'Verbose'),
204 default_value='Context', config=True)
202 default_value='Context', config=True)
@@ -1654,8 +1652,26 b' class InteractiveShell(Configurable, Magic):'
1654 #-------------------------------------------------------------------------
1652 #-------------------------------------------------------------------------
1655
1653
1656 def system(self, cmd):
1654 def system(self, cmd):
1657 """Make a system call, using IPython."""
1655 """Call the given cmd in a subprocess."""
1658 return self.hooks.shell_hook(self.var_expand(cmd, depth=2))
1656 # We do not support backgrounding processes because we either use
1657 # pexpect or pipes to read from. Users can always just call
1658 # os.system() if they really want a background process.
1659 if cmd.endswith('&'):
1660 raise OSError("Background processes not supported.")
1661
1662 return system(self.var_expand(cmd, depth=2))
1663
1664 def getoutput(self, cmd):
1665 """Get output (possibly including stderr) from a subprocess."""
1666 if cmd.endswith('&'):
1667 raise OSError("Background processes not supported.")
1668 return getoutput(self.var_expand(cmd, depth=2))
1669
1670 def getoutputerror(self, cmd):
1671 """Get stdout and stderr from a subprocess."""
1672 if cmd.endswith('&'):
1673 raise OSError("Background processes not supported.")
1674 return getoutputerror(self.var_expand(cmd, depth=2))
1659
1675
1660 #-------------------------------------------------------------------------
1676 #-------------------------------------------------------------------------
1661 # Things related to aliases
1677 # Things related to aliases
@@ -2056,16 +2072,6 b' class InteractiveShell(Configurable, Magic):'
2056 # Utilities
2072 # Utilities
2057 #-------------------------------------------------------------------------
2073 #-------------------------------------------------------------------------
2058
2074
2059 def getoutput(self, cmd):
2060 return getoutput(self.var_expand(cmd,depth=2),
2061 header=self.system_header,
2062 verbose=self.system_verbose)
2063
2064 def getoutputerror(self, cmd):
2065 return getoutputerror(self.var_expand(cmd,depth=2),
2066 header=self.system_header,
2067 verbose=self.system_verbose)
2068
2069 def var_expand(self,cmd,depth=0):
2075 def var_expand(self,cmd,depth=0):
2070 """Expand python variables in a string.
2076 """Expand python variables in a string.
2071
2077
@@ -614,23 +614,6 b' Currently the magic system has the following functions:\\n"""'
614
614
615 print "Automatic calling is:",['OFF','Smart','Full'][self.shell.autocall]
615 print "Automatic calling is:",['OFF','Smart','Full'][self.shell.autocall]
616
616
617 def magic_system_verbose(self, parameter_s = ''):
618 """Set verbose printing of system calls.
619
620 If called without an argument, act as a toggle"""
621
622 if parameter_s:
623 val = bool(eval(parameter_s))
624 else:
625 val = None
626
627 if self.shell.system_verbose:
628 self.shell.system_verbose = False
629 else:
630 self.shell.system_verbose = True
631 print "System verbose printing is:",\
632 ['OFF','ON'][self.shell.system_verbose]
633
634
617
635 def magic_page(self, parameter_s=''):
618 def magic_page(self, parameter_s=''):
636 """Pretty print the object and display it through a pager.
619 """Pretty print the object and display it through a pager.
General Comments 0
You need to be logged in to leave comments. Login now