Changeset 285
- Timestamp:
- 02/13/06 22:12:11 (3 years ago)
- Files:
-
- pycrash/trunk/crash/console.py (modified) (3 diffs)
- pycrash/trunk/crash/loader.py (modified) (1 diff)
- pycrash/trunk/crash/logger.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pycrash/trunk/crash/console.py
r284 r285 204 204 colwidths = [0] * cols 205 205 for i in range(0, cols): 206 colwidths[i] = max(map(lambda c: max( map(ctlen, c[i].splitlines())), table))206 colwidths[i] = max(map(lambda c: max([0] + map(ctlen, c[i].splitlines())), table)) 207 207 if i < cols - 1: 208 208 colwidths[i] += seplen … … 234 234 xrow = [cwraptext(col.replace('^R', fmt), colwidths[i] - (i < cols - 1 and seplen or 0)) for i, col in enumerate(row)] 235 235 # Pad column rows out to the maximum of all columns 236 maxrows = max( map(len, xrow))236 maxrows = max([0] + map(len, xrow)) 237 237 for col in xrow: 238 238 col += [''] * (maxrows - len(col)) 239 realrows = max( map(len, xrow))239 realrows = max([0] + map(len, xrow)) 240 240 # Emit 241 241 for i in range(0, realrows): … … 248 248 cwrite(sys.stdout, '^N\n') 249 249 rowalt += 1 250 251 try: 252 import msvcrt 253 def getch(): 254 return msvcrt.getch() 255 except ImportError: 256 import tty, sys, termios 257 258 def getch(): 259 fd = sys.stdin.fileno() 260 old_settings = termios.tcgetattr(fd) 261 try: 262 tty.setraw(sys.stdin.fileno()) 263 ch = sys.stdin.read(1) 264 finally: 265 termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) 266 return ch 267 268 getch.__doc__ = " Read a single character from stdin. " pycrash/trunk/crash/loader.py
r269 r285 49 49 # Return a reference to the class itself, not an instantiated object. 50 50 return aClass 51 52 def load_all(module): 53 """ Load all python modules in a module directory. Returns a tuple of 54 (success, failed) modules. """ 55 from dircache import listdir 56 import os 57 failed = [] 58 succeeded = [] 59 tried = [] 60 for p in module.__path__: 61 for f in listdir(p): 62 fp = os.path.join(p, f) 63 f, ext = os.path.splitext(f) 64 plugin = '.'.join((module.__name__, f)) 65 if plugin not in tried and not f.startswith('__') and (ext in 66 ('.so', '.py', '.pyc') or os.path.isdir(fp)): 67 tried.append(plugin) 68 try: 69 m = load_module(plugin) 70 succeeded.append(m) 71 except Exception, e: 72 failed.append((plugin, e)) 73 return (succeeded, failed) 74
