Handles the 'e' command.

        :args: Arguments supplied to the 'e' command.
777929
def edit(self, **args):
        
        if self.model.exists(args["index"]):
            values = dict(zip(
                ['parent', 'name', 'priority', 'comment', 'done'],
                self.model.get(args["index"])
            ))
            kwargs = self.getKwargs(args, values)
            if kwargs:
                self.model.edit(args["index"], **kwargs)
972258
def handle(self, *args, **options):
        
        self.pre_process(self.repo)
        self.handle_repo(self.repo, *args, **options)
        self.post_process(self.repo, **options)
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
1304239
def handle_command_line(options):
    
    options = merge(options, constants.DEFAULT_OPTIONS)
    engine = plugins.ENGINES.get_engine(
        options[constants.LABEL_TEMPLATE_TYPE],
        options[constants.LABEL_TMPL_DIRS],
        options[constants.LABEL_CONFIG_DIR],
    )
    if options[constants.LABEL_TEMPLATE] is None:
        if options[constants.POSITIONAL_LABEL_TEMPLATE] is None:
            raise exceptions.NoTemplate(constants.ERROR_NO_TEMPLATE)
        else:
            engine.render_string_to_file(
                options[constants.POSITIONAL_LABEL_TEMPLATE],
                options[constants.LABEL_CONFIG],
                options[constants.LABEL_OUTPUT],
            )
    else:
        engine.render_to_file(
            options[constants.LABEL_TEMPLATE],
            options[constants.LABEL_CONFIG],
            options[constants.LABEL_OUTPUT],
        )
    engine.report()
    HASH_STORE.save_hashes()
    exit_code = reporter.convert_to_shell_exit_code(
        engine.number_of_templated_files()
    )
    return exit_code
208181
def handle_error(self, e):
        
        got_request_exception.send(current_app._get_current_object(), exception=e)

        if not isinstance(e, HTTPException) and current_app.propagate_exceptions:
            exc_type, exc_value, tb = sys.exc_info()
            if exc_value is e:
                raise
            else:
                raise e

        headers = Headers()
        if isinstance(e, HTTPException):
            code = e.code
            default_data = {
                'message': getattr(e, 'description', http_status_message(code))
            }
            headers = e.get_response().headers
        else:
            code = 500
            default_data = {
                'message': http_status_message(code),
            }

        # Werkzeug exceptions generate a content-length header which is added
        # to the response in addition to the actual content-length header
        # https://github.com/flask-restful/flask-restful/issues/534
        remove_headers = ('Content-Length',)

        for header in remove_headers:
            headers.pop(header, None)

        data = getattr(e, 'data', default_data)

        if code and code >= 500:
            exc_info = sys.exc_info()
            if exc_info[1] is None:
                exc_info = None
            current_app.log_exception(exc_info)

        error_cls_name = type(e).__name__
        if error_cls_name in self.errors:
            custom_data = self.errors.get(error_cls_name, {})
            code = custom_data.get('status', 500)
            data.update(custom_data)

        if code == 406 and self.default_mediatype is None:
            # if we are handling NotAcceptable (406), make sure that
            # make_response uses a representation we support as the
            # default mediatype (so that make_response doesn't throw
            # another NotAcceptable error).
            supported_mediatypes = list(self.representations.keys())
            fallback_mediatype = supported_mediatypes[0] if supported_mediatypes else "text/plain"
            resp = self.make_response(
                data,
                code,
                headers,
                fallback_mediatype = fallback_mediatype
            )
        else:
            resp = self.make_response(data, code, headers)

        if code == 401:
            resp = self.unauthorized(resp)
        return resp
249504
def process_exception(self, request, e):
        
        if isinstance(e, RedirectException):
            response = e.get_response()
            self.process_response(request, response)
697009
def handle_default_args(args):
    

    if hasattr(args, 'pythonpath'):
        if args.pythonpath:
            sys.path.insert(0, args.pythonpath)
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
1361522
def handle_command(self, command):
        
        try:
            tree = secET.fromstring(command)
        except secET.ParseError:
            logger.debug("Erroneous client input: %s", command)
            raise OSPDError('Invalid data')

        if not self.command_exists(tree.tag) and tree.tag != "authenticate":
            raise OSPDError('Bogus command name')

        if tree.tag == "get_version":
            return self.handle_get_version_command()
        elif tree.tag == "start_scan":
            return self.handle_start_scan_command(tree)
        elif tree.tag == "stop_scan":
            return self.handle_stop_scan_command(tree)
        elif tree.tag == "get_scans":
            return self.handle_get_scans_command(tree)
        elif tree.tag == "get_vts":
            return self.handle_get_vts_command(tree)
        elif tree.tag == "delete_scan":
            return self.handle_delete_scan_command(tree)
        elif tree.tag == "help":
            return self.handle_help_command(tree)
        elif tree.tag == "get_scanner_details":
            return self.handle_get_scanner_details()
        else:
            assert False, "Unhandled command: {0}".format(tree.tag)
1041232
def execute(self, arg_list):
        
        arg_map = self.parser.parse_args(arg_list).__dict__
        command = arg_map.pop(self._COMMAND_FLAG)
        return command(**arg_map)
572263
def _handle_command(self, connection, sender, target, command, payload):
        
        try:
            # Find the handler
            handler = getattr(self, "cmd_{0}".format(command))
        except AttributeError:
            self.safe_send(connection, target, "Unknown command: %s",
                            command)
        else:
            try:
                logging.info("! Handling command: %s", command)
                handler(connection, sender, target, payload)
            except Exception as ex:
                logging.exception("Error calling command handler: %s", ex)
761837
def handle_exec(args):
    
    session_file = get_db_name(args.get('<session-file>'))
    cosmic_ray.commands.execute(session_file)

    return ExitCode.OK
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()
829832
def handle_help_command(self, scan_et):
        
        help_format = scan_et.attrib.get('format')
        if help_format is None or help_format == "text":
            # Default help format is text.
            return simple_response_str('help', 200, 'OK',
                                       self.get_help_text())
        elif help_format == "xml":
            text = self.get_xml_str(self.commands)
            return simple_response_str('help', 200, 'OK', text)
        raise OSPDError('Bogus help format', 'help')
934582
def _parse_arguments():
    
    parser = argparse.ArgumentParser(
        description='eg provides examples of common command usage.'
    )

    parser.add_argument(
        '-v',
        '--version',
        action='store_true',
        help='Display version information about eg'
    )

    parser.add_argument(
        '-f',
        '--config-file',
        help='Path to the .egrc file, if it is not in the default location.'
    )

    parser.add_argument(
        '-e',
        '--edit',
        action='store_true',
        help="""Edit the custom examples for the given command. If editor-cmd
        is not set in your .egrc and $VISUAL and $EDITOR are not set, prints a
        message and does nothing."""
    )

    parser.add_argument(
        '--examples-dir',
        help='The location to the examples/ dir that ships with eg'
    )

    parser.add_argument(
        '-c',
        '--custom-dir',
        help='Path to a directory containing user-defined examples.'
    )

    parser.add_argument(
        '-p',
        '--pager-cmd',
        help='String literal that will be invoked to page output.'
    )

    parser.add_argument(
        '-l',
        '--list',
        action='store_true',
        help='Show all the programs with eg entries.'
    )

    parser.add_argument(
        '--color',
        action='store_true',
        dest='use_color',
        default=None,
        help='Colorize output.'
    )

    parser.add_argument(
        '-s',
        '--squeeze',
        action='store_true',
        default=None,
        help='Show fewer blank lines in output.'
    )

    parser.add_argument(
        '--no-color',
        action='store_false',
        dest='use_color',
        help='Do not colorize output.'
    )

    parser.add_argument(
        'program',
        nargs='?',
        help='The program for which to display examples.'
    )

    args = parser.parse_args()

    if len(sys.argv) < 2:
        # Too few arguments. We can't specify this using argparse alone, so we
        # have to manually check.
        parser.print_help()
        parser.exit()
    elif not args.version and not args.list and not args.program:
        parser.error(_MSG_BAD_ARGS)
    else:
        return args
488771
def execute(self, env):
        

        # parse args
        parser = self._get_parser(env)
        parsed_args, cmd_args = parser.parse_known_args(env.args)

        # disable colors
        if parsed_args.no_color:
            env.io.set_colored(False)

        # run command handler passing any remaining args
        if not parsed_args.func(env, cmd_args):
            raise HelpBanner(parser.format_help())
1215538
def handle(self, *args, **options):
        """"""
        for index in options.pop("indexes"):
            data = {}
            try:
                data = self.do_index_command(index, **options)
            except TransportError as ex:
                logger.warning("ElasticSearch threw an error: %s", ex)
                data = {"index": index, "status": ex.status_code, "reason": ex.error}
            finally:
                logger.info(data)