def run_commands(self):
        """Automatically type and execute all commands."""
        more = 0
        prompt = sys.ps1
        for command in self.commands:
            try:
                prompt = sys.ps2 if more else sys.ps1
                try:
                    magictype(command, prompt_template=prompt, speed=self.speed)
                except EOFError:
                    self.write("\n")
                    break
                else:
                    if command.strip() == "exit()":
                        return
                    more = self.push(command)
            except KeyboardInterrupt:
                self.write("\nKeyboardInterrupt\n")
                self.resetbuffer()
                more = 0
                sys.exit(1)
        echo_prompt(prompt)
        wait_for(RETURNS)
def run_commands ( self ) : more = 0 prompt = sys . ps1 for command in self . commands : try : prompt = sys . ps2 if more else sys . ps1 try : magictype ( command , prompt_template = prompt , speed = self . speed ) except EOFError : self . write ( "\n" ) break else : if command . strip ( ) == "exit()" : return more = self . push ( command ) except KeyboardInterrupt : self . write ( "\nKeyboardInterrupt\n" ) self . resetbuffer ( ) more = 0 sys . exit ( 1 ) echo_prompt ( prompt ) wait_for ( RETURNS )
Automatically type and execute all commands.