diff --git a/IPython/hooks.py b/IPython/hooks.py index a80c91e..680aed4 100644 --- a/IPython/hooks.py +++ b/IPython/hooks.py @@ -32,7 +32,7 @@ ip.set_hook('editor', calljed) You can then enable the functionality by doing 'import myiphooks' somewhere in your configuration files or ipython command line. -$Id: hooks.py 2899 2007-12-28 08:32:59Z fperez $""" +$Id: hooks.py 2951 2008-01-19 11:32:18Z vivainio $""" #***************************************************************************** # Copyright (C) 2005 Fernando Perez. @@ -48,14 +48,14 @@ __license__ = Release.license __version__ = Release.version import os,bisect -from genutils import Term +from genutils import Term,shell from pprint import PrettyPrinter # List here all the default hooks. For now it's just the editor functions # but over time we'll move here all the public API for user-accessible things. __all__ = ['editor', 'fix_error_editor', 'result_display', 'input_prefilter', 'shutdown_hook', 'late_startup_hook', - 'generate_prompt', 'generate_output_prompt' ] + 'generate_prompt', 'generate_output_prompt','shell_hook'] pformat = PrettyPrinter().pformat @@ -213,3 +213,9 @@ def generate_prompt(self, is_continuation): def generate_output_prompt(self): ip = self.api return str(ip.IP.outputcache.prompt_out) + +def shell_hook(self,cmd): + """ Run system/shell command a'la os.system() """ + + shell(cmd, header=self.rc.system_header, verbose=self.rc.system_verbose) + diff --git a/IPython/iplib.py b/IPython/iplib.py index 8e20637..d00ff5b 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 2930 2008-01-11 07:03:11Z vivainio $ +$Id: iplib.py 2951 2008-01-19 11:32:18Z vivainio $ """ #***************************************************************************** @@ -490,9 +490,7 @@ class InteractiveShell(object,Magic): # The first is similar to os.system, but it doesn't return a value, # and it allows interpolation of variables in the user's namespace. self.system = lambda cmd: \ - shell(self.var_expand(cmd,depth=2), - header=self.rc.system_header, - verbose=self.rc.system_verbose) + self.hooks.shell_hook(self.var_expand(cmd,depth=2)) # These are for getoutput and getoutputerror: self.getoutput = lambda cmd: \