def cmd_debug(self, argv, help):
        """Prints some debug info for this script"""
        parser = argparse.ArgumentParser(
            prog="%s debug" % self.progname,
            description=help,
        )
        instances = self.instances
        parser.add_argument("instance", nargs=1,
                            metavar="instance",
                            help="Name of the instance from the config.",
                            choices=sorted(instances))
        parser.add_argument("-v", "--verbose", dest="verbose",
                            action="store_true", help="Print more info and output the startup script")
        parser.add_argument("-c", "--console-output", dest="console_output",
                            action="store_true", help="Prints the console output of the instance if available")
        parser.add_argument("-i", "--interactive", dest="interactive",
                            action="store_true", help="Creates a connection and drops you into an interactive Python session")
        parser.add_argument("-r", "--raw", dest="raw",
                            action="store_true", help="Outputs the raw possibly compressed startup script")
        parser.add_argument("-o", "--override", nargs="*", type=str,
                            dest="overrides", metavar="OVERRIDE",
                            help="Option to override instance config for startup script (name=value).")
        args = parser.parse_args(argv)
        overrides = self._parse_overrides(args)
        overrides['instances'] = self.instances
        instance = instances[args.instance[0]]
        if hasattr(instance, 'startup_script'):
            startup_script = instance.startup_script(overrides=overrides, debug=True)
            max_size = getattr(instance, 'max_startup_script_size', 16 * 1024)
            log.info("Length of startup script: %s/%s", len(startup_script['raw']), max_size)
            if args.verbose:
                if 'startup_script' in instance.config:
                    if startup_script['original'] == startup_script['raw']:
                        log.info("Startup script:")
                    elif args.raw:
                        log.info("Compressed startup script:")
                    else:
                        log.info("Uncompressed startup script:")
                else:
                    log.info("No startup script specified")
            if args.raw:
                print(startup_script['raw'], end='')
            elif args.verbose:
                print(startup_script['original'], end='')
        if args.console_output:
            if hasattr(instance, 'get_console_output'):
                print(instance.get_console_output())
            else:
                log.error("The instance doesn't support console output.")
        if args.interactive:  # pragma: no cover
            import readline
            from pprint import pprint
            local = dict(
                ctrl=self,
                instances=self.instances,
                instance=instance,
                pprint=pprint)
            readline.parse_and_bind('tab: complete')
            try:
                import rlcompleter
                readline.set_completer(rlcompleter.Completer(local).complete)
            except ImportError:
                pass
            __import__("code").interact(local=local)
def cmd_debug ( self , argv , help ) : parser = argparse . ArgumentParser ( prog = "%s debug" % self . progname , description = help , ) instances = self . instances parser . add_argument ( "instance" , nargs = 1 , metavar = "instance" , help = "Name of the instance from the config." , choices = sorted ( instances ) ) parser . add_argument ( "-v" , "--verbose" , dest = "verbose" , action = "store_true" , help = "Print more info and output the startup script" ) parser . add_argument ( "-c" , "--console-output" , dest = "console_output" , action = "store_true" , help = "Prints the console output of the instance if available" ) parser . add_argument ( "-i" , "--interactive" , dest = "interactive" , action = "store_true" , help = "Creates a connection and drops you into an interactive Python session" ) parser . add_argument ( "-r" , "--raw" , dest = "raw" , action = "store_true" , help = "Outputs the raw possibly compressed startup script" ) parser . add_argument ( "-o" , "--override" , nargs = "*" , type = str , dest = "overrides" , metavar = "OVERRIDE" , help = "Option to override instance config for startup script (name=value)." ) args = parser . parse_args ( argv ) overrides = self . _parse_overrides ( args ) overrides [ 'instances' ] = self . instances instance = instances [ args . instance [ 0 ] ] if hasattr ( instance , 'startup_script' ) : startup_script = instance . startup_script ( overrides = overrides , debug = True ) max_size = getattr ( instance , 'max_startup_script_size' , 16 * 1024 ) log . info ( "Length of startup script: %s/%s" , len ( startup_script [ 'raw' ] ) , max_size ) if args . verbose : if 'startup_script' in instance . config : if startup_script [ 'original' ] == startup_script [ 'raw' ] : log . info ( "Startup script:" ) elif args . raw : log . info ( "Compressed startup script:" ) else : log . info ( "Uncompressed startup script:" ) else : log . info ( "No startup script specified" ) if args . raw : print ( startup_script [ 'raw' ] , end = '' ) elif args . verbose : print ( startup_script [ 'original' ] , end = '' ) if args . console_output : if hasattr ( instance , 'get_console_output' ) : print ( instance . get_console_output ( ) ) else : log . error ( "The instance doesn't support console output." ) if args . interactive : import readline from pprint import pprint local = dict ( ctrl = self , instances = self . instances , instance = instance , pprint = pprint ) readline . parse_and_bind ( 'tab: complete' ) try : import rlcompleter readline . set_completer ( rlcompleter . Completer ( local ) . complete ) except ImportError : pass __import__ ( "code" ) . interact ( local = local )
Prints some debug info for this script