(self, cmdlist, fin=sys.stdin, fout=sys.stdout, ferr=None,
interactive=None, history_file=None)
| 68 | pass |
| 69 | |
| 70 | def __init__(self, cmdlist, fin=sys.stdin, fout=sys.stdout, ferr=None, |
| 71 | interactive=None, history_file=None): |
| 72 | self.cmdlist = cmdlist |
| 73 | |
| 74 | self.fin = fin |
| 75 | self.fout = fout |
| 76 | self.last_cmd = '' |
| 77 | self.rl = None |
| 78 | |
| 79 | if history_file is None: |
| 80 | try: |
| 81 | self.history_file = os.path.expanduser('~/.bess_history') |
| 82 | except: |
| 83 | self.history_file = None |
| 84 | else: |
| 85 | self.history_file = history_file |
| 86 | |
| 87 | # Colorize output to standard error |
| 88 | if ferr is None: |
| 89 | if os.environ.get('TERM') != 'dumb' and sys.stderr.isatty(): |
| 90 | self.ferr = ColorizedOutput(sys.stderr, '\033[31m') # dark red |
| 91 | else: |
| 92 | self.ferr = sys.stderr |
| 93 | else: |
| 94 | self.ferr = ferr |
| 95 | |
| 96 | if interactive is None: |
| 97 | self.interactive = fin.isatty() and fout.isatty() |
| 98 | else: |
| 99 | self.interactive = interactive |
| 100 | |
| 101 | if self.interactive: |
| 102 | self.go_interactive() |
| 103 | |
| 104 | def err(self, msg): |
| 105 | self.ferr.write('*** Error: %s\n' % msg) |
nothing calls this directly
no test coverage detected