Exemplo n.º 1
0
def interactive_console():
    publish('console-starting') 
    exit_requested = False
    while not exit_requested:
        try:
            for line in compmake_console():
                commands = line.strip().split()
                if commands:
                    try:
                        publish('command-starting', command=commands)
                        interpret_commands(commands)
                        publish('command-succeeded', command=commands)
                    except UserError as e:
                        publish('command-failed', command=commands, reason=e)
                        user_error(e)
                    except CompmakeException as e:
                        publish('command-failed', command=commands, reason=e)
                        # Added this for KeyboardInterrupt
                        error(e)
                    except KeyboardInterrupt:
                        publish('command-interrupted',
                                command=commands, reason='keyboard')
                        user_error('Execution of "%s" interrupted' % line)
                    except ShellExitRequested:
                        exit_requested = True
                        break
                    except Exception as e:
                        traceback.print_exc()
                        error('Warning, I got this exception, while it should have'
                              ' been filtered out already. This is a compmake BUG '
                              ' that should be reported:  %s' % e)
                        
        except KeyboardInterrupt:  # CTRL-C
            print "\nPlease use 'exit' to quit."
        except EOFError: # CTRL-D
            # TODO maybe make loop different? we don't want to catch
            # EOFerror in interpret_commands
            print "(end of input detected)"
            exit_requested = True
    
    publish('console-ending')
    return
Exemplo n.º 2
0
 def process_finished(self):
     if self.failed_hosts:
         error('The following hosts failed: %s.' % 
               ", ".join(list(self.failed_hosts)))