comparison lib/ipython_view.py @ 1866:3c523c71da29

pyflakes cleanups and some refactors Ignore-this: f7372e678699175feb4e628eee3d768c
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 25 May 2019 12:10:51 +0000
parents 547d65ea9902
children
comparison
equal deleted inserted replaced
1865:1aa91a31c0e2 1866:3c523c71da29
19 from gi.repository import Gdk 19 from gi.repository import Gdk
20 import re 20 import re
21 import sys 21 import sys
22 import os 22 import os
23 from gi.repository import Pango 23 from gi.repository import Pango
24 from StringIO import StringIO 24 from io import StringIO
25 from functools import reduce
25 26
26 try: 27 try:
27 import IPython 28 import IPython
28 except Exception,e: 29 except Exception as e:
29 raise "Error importing IPython (%s)" % str(e) 30 raise "Error importing IPython (%s)" % str(e)
30 31
31 ansi_colors = {'0;30': 'Black', 32 ansi_colors = {'0;30': 'Black',
32 '0;31': 'Red', 33 '0;31': 'Red',
33 '0;32': 'Green', 34 '0;32': 'Green',
146 return str1[:i] 147 return str1[:i]
147 return str1 148 return str1
148 149
149 def shell(self, cmd,verbose=0,debug=0,header=''): 150 def shell(self, cmd,verbose=0,debug=0,header=''):
150 stat = 0 151 stat = 0
151 if verbose or debug: print header+cmd 152 if verbose or debug: print(header+cmd)
152 # flush stdout so we don't mangle python's buffering 153 # flush stdout so we don't mangle python's buffering
153 if not debug: 154 if not debug:
154 input, output = os.popen4(cmd) 155 input, output = os.popen4(cmd)
155 print output.read() 156 print(output.read())
156 output.close() 157 output.close()
157 input.close() 158 input.close()
158 159
159 class ConsoleView(Gtk.TextView): 160 class ConsoleView(Gtk.TextView):
160 def __init__(self): 161 def __init__(self):