Django command handler.
511020
def handle(self, *args, **options):
        """"""
        self.verbosity = int(options.get('verbosity'))
        self.quiet = options.get('quiet')
        self._set_logger_level()

        self.servername = options.get('servername')
        self.decrypt = options.get('decrypt')
        self.uncompress = options.get('uncompress')

        self.filename = options.get('input_filename')
        self.path = options.get('input_path')

        self.replace = options.get('replace')
        self.passphrase = options.get('passphrase')
        self.interactive = options.get('interactive')

        self.storage = get_storage()
        self.media_storage = get_storage_class()()
        self._restore_backup()
177017
def feature_handler(self, cmd):
        """"""
        feature = cmd.feature_name
        if feature not in commands.FEATURE_NAMES:
            self.warning("feature %s is not supported - parsing may fail"
                % (feature,))
349662
def handle(self):
        
        self.output = PyStratumStyle(self.input, self.output)

        command = self.get_application().find('constants')
        ret = command.execute(self.input, self.output)
        if ret:
            return ret

        command = self.get_application().find('loader')
        ret = command.execute(self.input, self.output)
        if ret:
            return ret

        command = self.get_application().find('wrapper')
        ret = command.execute(self.input, self.output)

        self.output.writeln('')

        return ret
180655
function(name, handler, context){
      var command = this.storage.getCommands(name);

      // loop through and execute all the stored command instances
      _.each(command.instances, function(args){
        handler.apply(context, args);
      });

      this.storage.clearCommands(name);
    }
1084828
def handleArgs(self, event):
        """"""
        # settings resolution order:
        # command line > cfg file > environ
        if self.djsettings:
            os.environ['DJANGO_SETTINGS_MODULE'] = self.djsettings
        if self.djconfig:
            os.environ['DJANGO_CONFIGURATION'] = self.djconfig
        # test for django-configurations package
        try:
            from configurations import importer
            importer.install()
        except ImportError:
            pass
        from django.conf import settings

        try:
            from south.management.commands import patch_for_test_db_setup
            patch_for_test_db_setup()
        except ImportError:
            pass
688511
def add_command(self, handler, name=None):
        
        if name is None:
            name = docstring_to_subcommand(handler.__doc__)

        # TODO: Prevent overwriting 'help'?
        self._commands[name] = handler
436496
def run(command=None, *arguments):
    

    if command is None:
        sys.exit('django-shortcuts: No argument was supplied, please specify one.')

    if command in ALIASES:
        command = ALIASES[command]

    if command == 'startproject':
        return call('django-admin.py startproject %s' % ' '.join(arguments), shell=True)

    script_path = os.getcwd()
    while not os.path.exists(os.path.join(script_path, 'manage.py')):
        base_dir = os.path.dirname(script_path)
        if base_dir != script_path:
            script_path = base_dir
        else:
            sys.exit('django-shortcuts: No \'manage.py\' script found in this directory or its parents.')

    return call('%(python)s %(script_path)s %(command)s %(arguments)s' % {
        'python': sys.executable,
        'script_path': os.path.join(script_path, 'manage.py'),
        'command': command or '',
        'arguments': ' '.join(arguments)
    }, shell=True)
473728
def command(self, name, *args):
        """"""
        args = [name.encode('utf-8')] + [ (arg if type(arg) is bytes else str(arg).encode('utf-8'))
                for arg in args if arg is not None ] + [None]
        _mpv_command(self.handle, (c_char_p*len(args))(*args))
757310
def handle_command(editor, input_string):
    
    # Match with grammar and extract variables.
    m = COMMAND_GRAMMAR.match(input_string)
    if m is None:
        return

    variables = m.variables()
    command = variables.get('command')
    go_to_line = variables.get('go_to_line')
    shell_command = variables.get('shell_command')

    # Call command handler.

    if go_to_line is not None:
        # Handle go-to-line.
        _go_to_line(editor, go_to_line)

    elif shell_command is not None:
        # Handle shell commands.
        editor.application.run_system_command(shell_command)

    elif has_command_handler(command):
        # Handle other 'normal' commands.
        call_command_handler(command, editor, variables)
    else:
        # For unknown commands, show error message.
        editor.show_message('Not an editor command: %s' % input_string)
        return

    # After execution of commands, make sure to update the layout and focus
    # stack.
    editor.sync_with_prompt_toolkit()
764000
def command(self, rule, **options):
        
        options.setdefault("direct", False)
        options.setdefault("override", True)
        options.setdefault("inject", False)
        options.setdefault("flags", 0)
        if not options["direct"]:
            rule = self.regexy(rule)
        regex = re.compile(rule, flags=options["flags"])
        self.handlers.setdefault(regex, [])
        def handler(f):
            if f == noop:
                f.options = {}
            else:
                f.options = options
            if options["override"]:
                self.handlers[regex] = [f]
            else:
                self.handlers[regex].append(f)
            f.no_args = self.no_args(f)
            return f
        return handler
984065
def as_command(self):
        
        try:
            params = self.unbound_func.__click_params__
            params.reverse()
            del self.unbound_func.__click_params__
        except AttributeError:
            params = []
        help = inspect.getdoc(self.real_func)
        if isinstance(help, bytes):
            help = help.decode('utf-8')
        self.options.setdefault('help', help)
        @pass_script_info_decorator
        def callback(info, *args, **kwargs):
            if self.with_reloader:
                app = info.load_app()
                if app.debug:
                    def inner():
                        return self.command_callback(info, *args, **kwargs)
                    run_with_reloader(inner, extra_files=get_reloader_extra_files())
                    return
            self.command_callback(info, *args, **kwargs)
        return self.cls(name=self.name, callback=callback, params=params, **self.options)
934523
async def handler(event):
    """"""
    q1 = event.pattern_match.group(1)
    q2 = urllib.parse.quote(q1)
    await asyncio.wait([
        event.delete(),
        event.respond(DOCS.format(q1, q2), reply_to=event.reply_to_msg_id)
    ])
1302858
def handle(self, *args, **opt):
        
        d1_gmn.app.management.commands.util.util.log_setup(opt["debug"])
        logging.info(
            "Running management command: {}".format(
                __name__
            )  # util.get_command_name())
        )
        d1_gmn.app.management.commands.util.util.exit_if_other_instance_is_running(
            __name__
        )
        self._opt = opt
        try:
            # profiler = profile.Profile()
            # profiler.runcall(self._handle)
            # profiler.print_stats()
            self._handle()
        except d1_common.types.exceptions.DataONEException as e:
            logging.error(str(e))
            raise django.core.management.base.CommandError(str(e))
        self._events.dump_to_log()
521667
def handle(self, *args, **options):
        """"""
        verbosity = int(options.get('verbosity'))

        # Check that the specified output format is valid
        if options['format'] != 'plain' and options['format'] != 'yaml':
            raise CommandError("Unknown output format: %s" % options['format'])

        # Gather only unique latest custom Docker requirements that the processes are using
        # The 'image' field is optional, so be careful about that as well
        unique_docker_images = set(
            p.requirements['executor']['docker']['image']
            for p in Process.objects.filter(is_active=True).order_by(
                'slug', '-version'
            ).distinct(
                'slug'
            ).only(
                'requirements'
            ).filter(
                requirements__icontains='docker'
            )
            if 'image' in p.requirements.get('executor', {}).get('docker', {})
        )

        # Add the default image.
        unique_docker_images.add(DEFAULT_CONTAINER_IMAGE)

        # Pull images if requested or just output the list in specified format
        if options['pull']:
            # Remove set of already pulled images.
            with PULLED_IMAGES_LOCK:
                unique_docker_images.difference_update(PULLED_IMAGES)

            # Get the desired 'docker' command from settings or use the default
            docker = getattr(settings, 'FLOW_DOCKER_COMMAND', 'docker')

            # Pull each image
            for img in unique_docker_images:
                ret = subprocess.call(
                    shlex.split('{} pull {}'.format(docker, img)),
                    stdout=None if verbosity > 0 else subprocess.DEVNULL,
                    stderr=None if verbosity > 0 else subprocess.DEVNULL,
                )

                # Update set of pulled images.
                with PULLED_IMAGES_LOCK:
                    PULLED_IMAGES.add(img)

                if ret != 0:
                    errmsg = "Failed to pull Docker image '{}'!".format(img)

                    if not options['ignore_pull_errors']:
                        # Print error and stop execution
                        raise CommandError(errmsg)
                    else:
                        # Print error, but keep going
                        logger.error(errmsg)
                        if verbosity > 0:
                            self.stderr.write(errmsg)
                else:
                    msg = "Docker image '{}' pulled successfully!".format(img)
                    logger.info(msg)
                    if verbosity > 0:
                        self.stdout.write(msg)
        else:
            # Sort the set of unique Docker images for nicer output.
            unique_docker_images = sorted(unique_docker_images)

            # Convert the set of unique Docker images into a list of dicts for easier output
            imgs = [
                dict(name=s[0], tag=s[1] if len(s) == 2 else 'latest')
                for s in (img.split(':') for img in unique_docker_images)
            ]

            # Output in YAML or plaintext (one image per line), as requested
            if options['format'] == 'yaml':
                out = yaml.safe_dump(imgs, default_flow_style=True, default_style="'")
            else:
                out = functools.reduce(operator.add,
                                       ('{name}:{tag}\n'.format(**i) for i in imgs), '')

            self.stdout.write(out, ending='')
608943
def cmd(args, interact=False):
    """"""
    if isinstance(args, (str, bytes)):
        args = args.split()
    return CLI.cmd(args=args, interact=interact)
1045033
def _process_commands(self, commands):
        """"""
        if commands is None:
            return
        for cmd_list in commands:
            try:
                cmd_list = split_command_line(cmd_list)
                cmd = cmd_list[0]
                if cmd == 'gdb_port':
                    if len(cmd_list) < 2:
                        LOG.error("Missing port argument")
                    else:
                        self._args.port_number = int(cmd_list[1], base=0)
                elif cmd == 'telnet_port':
                    if len(cmd_list) < 2:
                        LOG.error("Missing port argument")
                    else:
                        self._args.telnet_port = int(cmd_list[1], base=0)
                elif cmd == 'echo':
                    self.echo_msg = ' '.join(cmd_list[1:])
                else:
                    LOG.error("Unsupported command: %s" % ' '.join(cmd_list))
            except IndexError:
                pass
548907
def _api_handler(self, *args, **kwargs):
        
        keyword_arguments = {}
        keyword_arguments.update(self.keywords)
        keyword_arguments.update(kwargs)
        return api_handler(*args, **keyword_arguments)