def _InteractiveLoop(self): """A typical coshell interactive loop.""" cosh = coshell.Coshell() prompt = '$ ' try: old_handler = signal.signal(signal.SIGINT, self._HandleInterrupt) while True: try: command = self._RawInput(prompt) except EOFError: if not cosh.ignore_eof: break sys.stdout.write('\b' * len(prompt)) continue except KeyboardInterrupt: sys.stdout.write('\n') continue if command == 'TEST-Interrupt': cosh.Interrupt() continue try: cosh.Run(command) except coshell.CoshellExitError: break finally: signal.signal(signal.SIGINT, old_handler) return cosh.Close()
def main(args=None, config=None): """The interactive application loop.""" cosh = coshell.Coshell() try: Application( args=args, cosh=cosh, config=config, ).Loop() finally: status = cosh.Close() sys.exit(status)
def main(args=None, config=None): """The interactive application loop.""" coshell = interactive_coshell.Coshell() try: Application( args=args, coshell=coshell, config=config, debug=interactive_debug.Debug(), ).Loop() finally: status = coshell.Close() sys.exit(status)
def CoOpen(self): if self.coshell: self.coshell.Close() sys.stdout.flush() sys.stderr.flush() old_out_fd = os.dup(1) new_out_fd = os.open(self.output_file, os.O_CREAT | os.O_WRONLY) os.dup2(new_out_fd, 1) os.close(new_out_fd) old_err_fd = os.dup(2) new_err_fd = os.open(self.error_file, os.O_CREAT | os.O_WRONLY) os.dup2(new_err_fd, 2) os.close(new_err_fd) self.coshell = coshell.Coshell() os.dup2(old_out_fd, 1) os.close(old_out_fd) os.dup2(old_err_fd, 2) os.close(old_err_fd)