def main(testrun=False): """Main.""" vim = Vim(testrun) try: try: vim.setlogger() vim.start() except (KeyboardInterrupt, SystemExit): pass except: t, v, filename, lnum, last_tb = misc.last_traceback() # get the line where exception occured try: lines, top = inspect.getsourcelines(last_tb) location = 'source line: "%s"\nat %s:%d' \ % (lines[lnum - top].strip(), filename, lnum) except IOError: sys.exc_clear() location = '' except_str = '\nException in pyclewn:\n\n' \ '%s\n"%s"\n%s\n\n' \ 'pyclewn aborting...\n' \ % (str(t), str(v), location) critical(except_str) vim.netbeans.show_balloon(except_str) finally: debug('Vim instance: ' + str(vim)) vim.shutdown()
def main(testrun=False): """Main. Return the vim instance to avoid its 'f_script' member to be garbage collected and the corresponding 'TmpFile' to be unlinked before Vim has a chance to start and source the file (only needed for the pdb test suite). """ vim = Vim(testrun, sys.argv[1:]) options = vim.options if options.pdb: if testrun: vim.debugger = vim.clazz(options) vim.spawn_vim() elif options.args: # run pdb to debug the 'args' python script _pdb(vim) else: # vim is running the command: 'Pyclewn pdb' # vim is attaching to a python process, # just write the vim script vim.vim_version() vim.clazz(options)._vim_script(options) return vim try: try: vim.debugger = vim.clazz(options) vim.setup(True) vim.loop() except (KeyboardInterrupt, SystemExit): pass except: t, v, filename, lnum, last_tb = misc.last_traceback() # get the line where exception occured try: lines, top = inspect.getsourcelines(last_tb) location = 'source line: "%s"\nat %s:%d' \ % (lines[lnum - top].strip(), filename, lnum) except IOError: sys.exc_clear() location = '' except_str = '\nException in pyclewn:\n\n' \ '%s\n"%s"\n%s\n\n' \ 'pyclewn aborting...\n' \ % (str(t), str(v), location) critical(except_str) if vim.nbserver.netbeans: vim.nbserver.netbeans.show_balloon(except_str) finally: debug('Vim instance: ' + str(vim)) vim.shutdown() return vim
def handle_result(self, result): """Process the result of the mi command.""" if self.mi: self.parse(result) # call the gdb.info method if hasattr(self, "action"): try: getattr(self.gdb.info, self.action)(self.cmd) except (KeyError, ValueError), err: t, v, filename, lnum, last_tb = misc.last_traceback() unused = (t, v, last_tb) error('Exception %s: "%s" at %s:%d', type(err), err, filename, lnum) info_attribute = getattr(self.gdb.info, self.info_attribute) if info_attribute: error("bad format: %s", info_attribute)
def ptyopen(self): """Spawn a process using a pseudo tty. Fall back to using pipes when failing to setup a pty. """ try: master = self.forkexec() except (ImportError, OSError, os.error, termios.error): t, v, filename, lnum, unused = misc.last_traceback() error("failed to setup a pseudo tty, falling back to pipes:") error(" %s: %s", str(t), str(v)) error(" at %s:%s", filename, lnum) self.popen() else: pty = asyncproc.FileAsynchat(master, self, map=self.socket_map) self.fileasync = (pty, pty) info('starting "%s" with a pseudo tty', self.pgm_name)
def main(testrun=False): """Main. Return the vim instance to avoid its 'f_script' member to be garbage collected and the corresponding 'TmpFile' to be unlinked before Vim has a chance to start and source the file (only needed for the pdb test suite). """ vim = Vim(testrun, sys.argv[1:]) options = vim.options if options.pdb: if testrun: vim.debugger = vim.clazz(options) vim.spawn_vim() elif options.args: # run pdb to debug the 'args' python script _pdb(vim) else: # vim is running the command: 'Pyclewn pdb' # vim is attaching to a python process, # just write the vim script vim.vim_version() vim.clazz(options)._vim_script(options) return vim except_str = '' try: gdb_pty = None if os.name != 'nt' and not testrun: gdb_pty = tty.GdbInferiorPty(vim.stderr_hdlr) try: if (vim.clazz == gdb.Gdb and gdb_pty and not options.daemon and os.isatty(sys.stdin.fileno())): # Use pyclewn pty as the debuggee standard input and output, but # not when vim is run as 'vim' or 'vi'. vim_pgm = os.path.basename(options.editor) if vim_pgm != 'vim' and vim_pgm != 'vi': gdb_pty.start() options.tty = gdb_pty.ptyname vim.debugger = vim.clazz(options) vim.setup(True) vim.loop() except (KeyboardInterrupt, SystemExit): pass except: t, v, filename, lnum, last_tb = misc.last_traceback() # get the line where exception occured try: lines, top = inspect.getsourcelines(last_tb) location = 'source line: "%s"\nat %s:%d' \ % (lines[lnum - top].strip(), filename, lnum) except IOError: sys.exc_clear() location = '' except_str = '\nException in pyclewn:\n\n' \ '%s\n"%s"\n%s\n\n' \ 'pyclewn aborting...\n' \ % (str(t), str(v), location) critical(except_str) if vim.nbserver.netbeans: vim.nbserver.netbeans.show_balloon(except_str) finally: if gdb_pty: gdb_pty.close() debug('Vim instance: ' + str(vim)) vim.shutdown() if os.name == 'nt' and except_str: time.sleep(5) return vim
def main(testrun=False): """Main. Return the vim instance to avoid its 'f_script' member to be garbage collected and the corresponding 'TmpFile' to be unlinked before Vim has a chance to start and source the file (only needed for the pdb test suite). """ vim = Vim(testrun, sys.argv[1:]) options = vim.options if options.pdb: if testrun: vim.create_debugger() vim.spawn_vim() vim.shutdown() elif options.args: # run pdb to debug the 'args' python script _pdb(vim) else: # vim is running the command: 'Pyclewn pdb' # vim is attaching to a python process, # just write the vim script vim.vim_version() vim.create_debugger()._vim_script(options) return vim except_str = '' try: gdb_pty = None if os.name != 'nt' and not testrun: gdb_pty = tty.GdbInferiorPty(vim.stderr_hdlr, vim.socket_map) try: if (vim.clazz == gdb.Gdb and gdb_pty and not options.daemon and os.isatty(sys.stdin.fileno())): # Use pyclewn pty as the debuggee standard input and output, but # not when vim is run as 'vim' or 'vi'. vim_pgm = os.path.basename(options.editor) if vim_pgm != 'vim' and vim_pgm != 'vi': gdb_pty.start() options.tty = gdb_pty.ptyname vim.create_debugger(testrun) vim.setup(True) vim.loop() except (KeyboardInterrupt, SystemExit): pass except: t, v, filename, lnum, last_tb = misc.last_traceback() # get the line where exception occured try: lines, top = inspect.getsourcelines(last_tb) location = 'source line: "%s"\nat %s:%d' \ % (lines[lnum - top].strip(), filename, lnum) except IOError: sys.exc_clear() location = '' except_str = '\nException in pyclewn:\n\n' \ '%s\n"%s"\n%s\n\n' \ 'pyclewn aborting...\n' \ % (str(t), str(v), location) critical(except_str) if vim.nbserver.netbeans: vim.nbserver.netbeans.show_balloon(except_str) finally: if gdb_pty: gdb_pty.close() debug('Vim instance: ' + str(vim)) vim.shutdown() if os.name == 'nt' and except_str: time.sleep(5) return vim