Ejemplo n.º 1
0
    def execute(self, argv):

        try:
            opts, args = getopt.gnu_getopt(
                argv, 'v',
                ['as-current-user', 'jdb', 'verbose', 'debug', 'help'])

        except getopt.GetoptError as e:
            logger.error(e)
            self.print_help()
            sys.exit(1)

        instance_name = 'pki-tomcat'
        as_current_user = False
        jdb = False
        gdb = False

        for o, _ in opts:
            if o == '--as-current-user':
                as_current_user = True

            elif o == '--gdb':
                gdb = True

            elif o == '--jdb':
                jdb = True

            elif o in ('-v', '--verbose'):
                logging.getLogger().setLevel(logging.INFO)

            elif o == '--debug':
                logging.getLogger().setLevel(logging.DEBUG)

            elif o == '--help':
                self.print_help()
                sys.exit()

            else:
                logger.error('Unknown option: %s', o)
                self.print_help()
                sys.exit(1)

        if len(args) > 0:
            instance_name = args[0]

        instance = pki.server.instance.PKIServerFactory.create(instance_name)

        if not instance.is_valid():
            logger.error('Invalid instance: %s', instance_name)
            sys.exit(1)

        instance.load()

        try:
            instance.run(gdb=gdb, jdb=jdb, as_current_user=as_current_user)

        except KeyboardInterrupt:
            logging.debug('Server stopped')
Ejemplo n.º 2
0
    def execute(self, argv):

        try:
            opts, args = getopt.gnu_getopt(argv, 'v', [
                'as-current-user', 'with-jdb', 'with-gdb', 'with-valgrind',
                'agentpath=', 'verbose', 'debug', 'help'
            ])

        except getopt.GetoptError as e:
            logger.error(e)
            self.print_help()
            sys.exit(1)

        instance_name = 'pki-tomcat'
        as_current_user = False
        with_jdb = False
        with_gdb = False
        with_valgrind = False
        agentpath = None

        for o, a in opts:
            if o == '--as-current-user':
                as_current_user = True

            elif o == '--with-jdb':
                with_jdb = True

            elif o == '--with-gdb':
                with_gdb = True

            elif o == '--with-valgrind':
                with_valgrind = True

            elif o == '--agentpath':
                agentpath = a

            elif o in ('-v', '--verbose'):
                logging.getLogger().setLevel(logging.INFO)

            elif o == '--debug':
                logging.getLogger().setLevel(logging.DEBUG)

            elif o == '--help':
                self.print_help()
                sys.exit()

            else:
                logger.error('Unknown option: %s', o)
                self.print_help()
                sys.exit(1)

        if len(args) > 0:
            instance_name = args[0]

        instance = pki.server.instance.PKIServerFactory.create(instance_name)

        if not instance.exists():
            logger.error('Invalid instance: %s', instance_name)
            sys.exit(1)

        instance.load()

        try:
            instance.run(as_current_user=as_current_user,
                         with_jdb=with_jdb,
                         with_gdb=with_gdb,
                         with_valgrind=with_valgrind,
                         agentpath=agentpath)

        except KeyboardInterrupt:
            logger.debug('Server stopped')