Ejemplo n.º 1
0
    def showsyntaxerror(self, filename=None):
        """ when a syntax error is encountered,
            consider just broadcasting a signal instead
            of showing a traceback.
        """
        smash_log.info(
            "last efforts to do something "
            "meaningful with input before "
            "syntax error")
        lastline = self._smash_last_input
        clean_line = lastline.strip()
        if not clean_line:
            # this is not input!
            # possibly there is actually an error in smash itself
            raise

        if is_path(clean_line):
            # NB: in this case a regex looks like a path or URL,
            # but it's not necessarily true that the endpoint
            # actuals exists
            smash_log.info("detected path input: {0}".format(clean_line))
            self.smash.publish(C_FILE_INPUT, clean_line)
        elif is_path(clean_line.split()[0]):
            self.system(clean_line)
        else:
            smash_log.info('nothing to do but call super()')
            sooper = super(SmashTerminalInteractiveShell, self)
            return sooper.showsyntaxerror(filename=filename)
Ejemplo n.º 2
0
 def handle_NameError(self, last_line, etype, evalue):
     if etype != NameError:
         return
     if is_path(last_line):
         #smash_log.info("detected path input: {0}".format(clean_line))
         return self.on_file_input('fake_bus', last_line)