Ejemplo n.º 1
0
    def __init__(self, verbosity, encoding, **unused):
        PexpectMixin.__init__(
            self,
            PS1_re=r'_byexample iex _byexample/iex> ',
            any_PS_re=r'_byexample (iex|\.\.\.) _byexample/iex> ')

        self.encoding = encoding
Ejemplo n.º 2
0
 def _change_terminal_geometry(self, rows, cols, options):
     # update the pretty printer with the new columns value
     source = '__byexample_pretty_print.update_width(%i)' % cols
     self._exec_and_wait(source,
                         options,
                         timeout=options['x']['dfl_timeout'])
     PexpectMixin._change_terminal_geometry(self, rows, cols, options)
Ejemplo n.º 3
0
    def _expect_prompt(self,
                       options,
                       countdown,
                       prompt_re=None,
                       earlier_re=None):
        if options['stop_on_silence'] is not False:
            prev = 0
            while 1:
                tmp = min(options['stop_on_silence'], countdown.left())
                silence_countdown = Countdown(tmp)
                try:
                    countdown.start()
                    try:
                        return PexpectMixin._expect_prompt(
                            self, options, silence_countdown, prompt_re,
                            earlier_re)
                    finally:
                        countdown.stop()
                except TimeoutException as ex:
                    # a real timeout
                    if countdown.did_run_out(
                    ) or silence_countdown.did_run_out():
                        raise

                    # inactivity or silence detected
                    if prev >= len(ex.output):
                        raise

                    prev = len(ex.output)

        else:
            return PexpectMixin._expect_prompt(self, options, countdown,
                                               prompt_re, earlier_re)
Ejemplo n.º 4
0
    def _expect_prompt(self, options, timeout, prompt_re=None):
        if options['stop_on_silence'] is not False:
            silence_timeout = options['stop_on_silence']
            prev = 0
            while 1:
                try:
                    begin = time.time()
                    return PexpectMixin._expect_prompt(self, options,
                                                       silence_timeout,
                                                       prompt_re)
                except TimeoutException as ex:
                    timeout -= max(time.time() - begin, 0)
                    silence_timeout = min(silence_timeout, timeout)

                    # a real timeout
                    if timeout <= 0 or silence_timeout <= 0:
                        raise

                    # inactivity or silence detected
                    if prev >= len(ex.output):
                        raise

                    prev = len(ex.output)

        else:
            return PexpectMixin._expect_prompt(self, options, timeout,
                                               prompt_re)
Ejemplo n.º 5
0
    def __init__(self, verbosity, encoding, **unused):
        self.encoding = encoding

        PexpectMixin.__init__(
            self,
            PS1_re=r'\[cling\]\$',  # [cling]$
            any_PS_re=r'\[cling\][$!](?: \?)?'
        )  # [cling]!
Ejemplo n.º 6
0
    def __init__(self, verbosity, encoding, **unused):
        self.encoding = encoding

        self._PS1 = r'/byexample/py/ps1> '
        self._PS2 = r'/byexample/py/ps2> '

        PexpectMixin.__init__(self,
                              PS1_re=self._PS1,
                              any_PS_re=r'/byexample/py/ps\d> ')
Ejemplo n.º 7
0
    def __init__(self, verbosity, encoding, **unused):
        self.encoding = encoding

        # --nh     do not read ~/.gdbinit
        # --nx     do not read any .gdbinit
        # --quiet  do not print version number on startup
        PexpectMixin.__init__(self,
                              PS1_re=r'\(gdb\)[ ]',
                              any_PS_re=r'\(gdb\)[ ]')
Ejemplo n.º 8
0
    def __init__(self, verbosity, encoding, **unused):
        PexpectMixin.__init__(
            self,
            # the format is '/byexample/php/ blk chr >'
            # where blk indicates in which block we are
            # and chr indicates in which unterminated block
            # we are
            PS1_re=r'/byexample/php/\s+php\s+>\s+> ',
            any_PS_re=r'/byexample/php/\s+[^ ]+\s+[^ ]+\s+> ')

        self.encoding = encoding
Ejemplo n.º 9
0
    def run(self, example, options):
        # the algorithm to filter the echos from the interpreter's output
        # (see _get_output()) doesn't work if the terminal is resized
        # so we disable this:
        options['geometry'] = self._terminal_default_geometry

        # interpreter's output requeries to be emulated by an ANSI Terminal
        # so we force this (see _get_output())
        options['term'] = 'ansi'

        return PexpectMixin._run(self, example, options)
Ejemplo n.º 10
0
 def interact(self, example, options):
     PexpectMixin.interact(self)
Ejemplo n.º 11
0
 def run(self, example, options):
     return PexpectMixin._run(self, example, options)
Ejemplo n.º 12
0
    def __init__(self, verbosity, encoding, **unused):
        PexpectMixin.__init__(self,
                              PS1_re=r'irb[^:]*:\d+:0(>|\*) ',
                              any_PS_re=r'irb[^:]*:\d+:\d+(>|\*|") ')

        self.encoding = encoding
Ejemplo n.º 13
0
    def __init__(self, verbosity, encoding, **unused):
        PexpectMixin.__init__(self,
                              PS1_re=r'node > ',
                              any_PS_re=r'(?:node > )|(?:\.\.\. )')

        self.encoding = encoding
Ejemplo n.º 14
0
    def __init__(self, verbosity, encoding, **unused):
        self.encoding = encoding

        PexpectMixin.__init__(self,
                              PS1_re=r"/byexample/sh/ps1> ",
                              any_PS_re=r"/byexample/sh/ps\d+> ")