示例#1
0
    def __init__(self, configuration=None):
        self._event_handlers = defaultdict(lambda: [])
        self.session = {
            'headers': {
                'x-ms-client-request-id': str(uuid.uuid1())
            },
            'command': 'unknown',
            'completer_active': ARGCOMPLETE_ENV_NAME in os.environ,
            'query_active': False
        }

        # Register presence of and handlers for global parameters
        self.register(self.GLOBAL_PARSER_CREATED, Application._register_builtin_arguments)
        self.register(self.COMMAND_PARSER_PARSED, self._handle_builtin_arguments)

        # Let other extensions make their presence known
        azure.cli.core.extensions.register_extensions(self)

        self.global_parser = AzCliCommandParser(prog='az', add_help=False)
        global_group = self.global_parser.add_argument_group('global', 'Global Arguments')
        self.raise_event(self.GLOBAL_PARSER_CREATED, global_group=global_group)

        self.parser = AzCliCommandParser(prog='az', parents=[self.global_parser])
        self.configuration = configuration
        self.progress_controller = progress.ProgressHook()
示例#2
0
    def get_progress_controller(self, det=False):
        import azure.cli.core.commands.progress as progress
        if not self.progress_controller:
            self.progress_controller = progress.ProgressHook()

        self.progress_controller.init_progress(progress.get_progress_view(det))
        return self.progress_controller
示例#3
0
    def get_progress_controller(self, det=False, spinner=None):
        from azure.cli.core.commands import progress
        if not self.progress_controller:
            self.progress_controller = progress.ProgressHook()

        self.progress_controller.init_progress(
            progress.get_progress_view(det, spinner=spinner))
        return self.progress_controller
示例#4
0
    def test_progress_indicator_controller(self):
        """ tests the controller for progress reporting """
        controller = progress.ProgressHook()
        view = MockOutstream()

        controller.init_progress(view)
        self.assertTrue(view == controller.active_progress)

        controller.begin()

        self.assertEqual(controller.active_progress.string['message'], 'Starting')

        controller.end()
        self.assertEqual(controller.active_progress.string['message'], 'Finished')