Changeset 2954
- Timestamp:
- 01/19/08 08:28:18 (11 months ago)
- Files:
-
- ipython/trunk/IPython/gui/wx/ipython_view.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ipython/trunk/IPython/gui/wx/ipython_view.py
r2934 r2954 108 108 109 109 #we replace the ipython default shell command caller by our shell handler 110 #FIXME: any better solution welcome 111 IPython.genutils.shell_ori = self._shell #needed by windows 112 self._IP.system = self._shell #needed for linux 110 self._IP.set_hook('shell_hook',self._shell) 111 113 112 #we replace the ipython default input command caller by our method 114 113 IPython.iplib.raw_input_original = self._raw_input … … 406 405 sys.stdout = orig_stdout 407 406 408 def _shell(self, cmd,verbose=0,debug=0,header=''):407 def _shell(self, ip, cmd): 409 408 ''' 410 409 Replacement method to allow shell commands without them blocking. 411 410 411 @param ip: Ipython instance, same as self._IP 412 @type cmd: Ipython instance 412 413 @param cmd: Shell command to execute. 413 414 @type cmd: string 414 @param verbose: Verbosity 415 @type verbose: integer 416 @param debug: Debug level 417 @type debug: integer 418 @param header: Header to be printed before output 419 @type header: string 420 ''' 421 if verbose or debug: print header+cmd 422 # flush stdout so we don't mangle python's buffering 423 if not debug: 424 stdin, stdout = os.popen4(cmd) 425 result = stdout.read().decode('cp437').encode(locale.getpreferredencoding()) 426 #we use print command because the shell command is called inside IPython instance and thus is 427 #redirected to thread cout 428 #"\x01\x1b[1;36m\x02" <-- add colour to the text... 429 print "\x01\x1b[1;36m\x02"+result 430 stdout.close() 431 stdin.close() 415 ''' 416 stdin, stdout = os.popen4(cmd) 417 result = stdout.read().decode('cp437').encode(locale.getpreferredencoding()) 418 #we use print command because the shell command is called inside IPython instance and thus is 419 #redirected to thread cout 420 #"\x01\x1b[1;36m\x02" <-- add colour to the text... 421 print "\x01\x1b[1;36m\x02"+result 422 stdout.close() 423 stdin.close() 432 424 433 425 class WxConsoleView(stc.StyledTextCtrl):
