Changeset 2951

Show
Ignore:
Timestamp:
01/19/08 05:32:18 (11 months ago)
Author:
vivainio
Message:

added 'shell_hook' for hooking own 'system()' implementations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ipython/trunk/IPython/hooks.py

    r2899 r2951  
    4949 
    5050import os,bisect 
    51 from genutils import Term 
     51from genutils import Term,shell 
    5252from pprint import PrettyPrinter 
    5353 
     
    5656__all__ = ['editor', 'fix_error_editor', 'result_display', 
    5757           'input_prefilter', 'shutdown_hook', 'late_startup_hook', 
    58            'generate_prompt', 'generate_output_prompt'
     58           'generate_prompt', 'generate_output_prompt','shell_hook'
    5959 
    6060pformat = PrettyPrinter().pformat 
     
    214214    ip = self.api 
    215215    return str(ip.IP.outputcache.prompt_out) 
     216 
     217def shell_hook(self,cmd): 
     218    """ Run system/shell command a'la os.system() """ 
     219 
     220    shell(cmd, header=self.rc.system_header, verbose=self.rc.system_verbose) 
     221 
  • ipython/trunk/IPython/iplib.py

    r2930 r2951  
    491491        # and it allows interpolation of variables in the user's namespace. 
    492492        self.system = lambda cmd: \ 
    493                       shell(self.var_expand(cmd,depth=2), 
    494                             header=self.rc.system_header, 
    495                             verbose=self.rc.system_verbose) 
     493                      self.hooks.shell_hook(self.var_expand(cmd,depth=2)) 
    496494 
    497495        # These are for getoutput and getoutputerror: