Initialize manager
 Handle stats request

 === Parameters
 options(Hash):: Command line options

 === Return
 true:: Always return true
174394
def manage(options)
      init_log if options[:verbose]
      AgentConfig.cfg_dir = options[:cfg_dir]
      options[:timeout] ||= DEFAULT_TIMEOUT
      request_stats(options)
    rescue Exception => e
      fail("#{e}\n#{e.backtrace.join("\n")}") unless e.is_a?(SystemExit)
    end
228137
def handle(self, **options):
        
        super(Command, self).handle(**options)
        return "{} static file{} copied.".format(
            self.num_copied_files,
            '' if self.num_copied_files == 1 else 's')
646310
def main(args=None):
    
    # Base command line parser. Help is not allowed because command
    # line is parsed in two stages - in the first stage is found setting
    # module of the application, in the second stage are found management
    # command's arguments.
    parser = ArgumentParser(add_help=False)
    parser.add_argument(
        '-s', '--settings',
        dest='settings', action='store', type=str, default=None,
        help=_('application settings module')
    )

    # Get settings module
    try:
        settings = get_app_settings(parser, args)
    except ImportError as exc:
        parser.error(_("Invalid application settings module: {}").format(exc))

    # Get management commands and add their arguments into command
    # line parser
    commands = get_management_commands(settings)
    subparsers = parser.add_subparsers(
        dest='action', help=_('specify action')
    )
    for command_cls in six.itervalues(commands):
        subparser = subparsers.add_parser(
            command_cls.name, help=command_cls.help)
        for command_args, kwargs in command_cls.arguments:
            subparser.add_argument(*command_args, **kwargs)

    # Get config class and add its arguments into command line parser
    if settings:
        config_cls = get_config_class(settings)
        if not issubclass(config_cls, Config):
            raise TypeError(
                "Config class must be subclass of the "
                "shelter.core.config.Config")
        for config_args, kwargs in config_cls.arguments:
            parser.add_argument(*config_args, **kwargs)
    else:
        config_cls = Config

    # Add help argument and parse command line
    parser.add_argument(
        '-h', '--help', action='help',
        help=_('show this help message and exit')
    )
    cmdline_args = parser.parse_args(args)
    if not cmdline_args.action:
        parser.error(_('No action'))

    # Run management command
    command_cls = commands[cmdline_args.action]
    if command_cls.settings_required and not settings:
        parser.error(_(
            "Settings module is not defined. You must either set "
            "'SHELTER_SETTINGS_MODULE' environment variable or "
            "'-s/--settings' command line argument."
        ))
    try:
        config = config_cls(settings, cmdline_args)
    except ImproperlyConfiguredError as exc:
        parser.error(str(exc))
    command = command_cls(config)
    try:
        command()
    except Exception:
        traceback.print_exc(file=sys.stderr)
        sys.stderr.flush()
        if multiprocessing.active_children():
            # If main process has children processes, exit immediately without
            # cleaning. It is a workaround, because parent process waits for
            # non-daemon children.
            os._exit(1)
        sys.exit(1)
    sys.exit(0)
1219987
def handle_options
      options.rakelib = ['rakelib']
      options.trace_output = $stderr

      OptionParser.new do |opts|
        opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..."
        opts.separator ""
        opts.separator "Options are ..."

        opts.on_tail("-h", "--help", "-H", "Display this help message.") do
          puts opts
          exit
        end

        standard_rake_options.each { |args| opts.on(*args) }
        opts.environment('RAKEOPT')
      end.parse!
    end
439681
def execute(opts={}, &block)
      parse_options
      self.options.merge!(opts)

      @verify_options_hook.call(self.options) if @verify_options_hook

      if options.include?(:kill)
        self.stop
      else # create process
        self.stop if options.include?(:restart)

        # If a username, uid, groupname, or gid is passed,
        # drop privileges accordingly.

        if options[:group]
          gid = options[:group].is_a?(Integer) ? options[:group] : Etc.getgrnam(options[:group]).gid
          Process::GID.change_privilege(gid)
        end

        if options[:user]
          uid = options[:user].is_a?(Integer) ? options[:user] : Etc.getpwnam(options[:user]).uid
          Process::UID.change_privilege(uid)
        end

        @startup_command = block if block_given?
        options[:daemonize] ? daemonize : start
      end
    end
155117
def handle(self, *args, **options):
        
        counter = 0
        for key in options:
            if options[key]:
                counter += 1

        # If no options are set, do a normal patch
        if counter == 1:
            options['default'] = True
        ###########################################################################################

        tag_succeed = 1

        if APISettings.GIT_TAG_AUTO_COMMIT:
            Git.add()
            Git.commit()

        if options['default']:
            tag_succeed = Git.tag()

        if options['staging']:
            tag_succeed = Git.tag(APISettings.GIT_STAGING_PRE_TAG)

        if options['production']:
            tag_succeed = Git.tag(APISettings.GIT_ACTIVATE_PRE_TAG)

        if options['push'] | APISettings.GIT_TAG_AUTO_TAG_PUSH:
            if tag_succeed:
                Git.push_tags()
278703
def execute_command_in_message(controller, cliargs, clioptions, message):
    
    SUPPORTED_COMMANDS = ['start'] # , 'stop'] # TODO
    print(message)

    # args and options from SushiBar overrride command line args and options
    args = cliargs
    options = clioptions
    if 'args' in message:
        args.update(message['args'])
    if 'options' in message:
        options.update(message['options'])

    if message['command'] == 'start':
        if not controller.thread or not controller.thread.isAlive():
            controller.thread = threading.Thread(
                target=controller.chef.run,
                args=(args, options),
            )
            controller.thread.start()
        else:
            config.LOGGER.info('Not starting because chef is already running.')
    else:
        config.LOGGER.info('Command not supported: %s' % message['command'])
1108282
def default_options(options = {})
      headers = default_headers.merge(options[:headers] || {})
      headers.merge!({USER_AGENT => options[:user_agent]})
      {
        headers: headers,
        ssl: options[:ssl],
        url: options[:endpoint]
      }
    end
688103
def options(self, *args, **kwargs):
        
        self.set_header('Allow', ', '.join(self.ALLOW))
        self.set_status(204)
        self.finish()
218332
def setup_options_parser
      @options_parser = OptionParser.new do |opts|
        opts.banner = "\nUsage: fission [options] COMMAND [arguments]"

        opts.on_head('-v', '--version', 'Output the version of fission') do
          ui.output VERSION
          exit 0
        end

        opts.on_head('-h', '--help', 'Displays this message') do
          show_all_help
          exit 0
        end
      end
    end
996293
def handle(self, **options):
        
        self.flushdb = options.get('flushdb')
        self._pre_tasks()
        self._create_users()
        self._create_badges()
        self._create_awards()
182360
def handle_argv(self, prog_name, argv):
        
        options, args = self.parse_options(prog_name, argv)
        return self.run(*args, **vars(options))
954398
def execute
      cli_arguments = Telegram::CLIArguments.new(@config)
      command = "'#{@config.daemon}' #{cli_arguments.to_s}"
      @stdout = IO.popen(command, 'a+')
      initialize_stdout_reading
    end
1127561
def _set_command_line_arguments(self, args):
        
        Global.LOGGER.debug("setting command line arguments")

        if args.VERBOSE:
            Global.LOGGER.debug("verbose mode active")
            Global.CONFIG_MANAGER.log_level = logging.DEBUG
            Global.LOGGER_INSTANCE.reconfigure_log_level()

        if args.STATS > 0:
            Global.LOGGER.debug(f"stats requested every {args.STATS} seconds")
            Global.CONFIG_MANAGER.show_stats = True
            Global.CONFIG_MANAGER.stats_timeout = args.STATS

        if args.INTERVAL > 0:
            Global.LOGGER.debug(f"setting sleep interval to {args.INTERVAL} milliseconds")
            Global.CONFIG_MANAGER.sleep_interval = float(args.INTERVAL)/1000

        if args.TRACE:
            Global.LOGGER.debug("tracing mode active")
            Global.CONFIG_MANAGER.tracing_mode = True
            Global.CONFIG_MANAGER.log_level = logging.DEBUG
            Global.LOGGER_INSTANCE.reconfigure_log_level()

        if  args.MESSAGEINTERVAL is not None and args.MESSAGEINTERVAL > 0:
            Global.LOGGER.debug(f"setting message fetcher sleep interval to {args.MESSAGEINTERVAL/10} milliseconds")
            Global.CONFIG_MANAGER.message_fetcher_sleep_interval =  float(args.MESSAGEINTERVAL)/10000
            Global.CONFIG_MANAGER.fixed_message_fetcher_interval = True

        Global.LOGGER.debug(f"recipes to be parsed: {args.FILENAME}")
        Global.CONFIG_MANAGER.recipes = (args.FILENAME)
576204
def init_log
      Log.program_name = "stats_manager"
      Log.log_to_file_only(true)
      Log.init("stats_manager", Platform.filesystem.temp_dir, :print => true)
      RightSupport::Log::Mixin.default_logger = Log
      true
    end
718984
def create_params params
      options = {}
      options[:query] = params

      if @auth_token
        options[:query].merge!(auth_token: @auth_token)
      else
        options[:basic_auth] = @auth
      end

      options
    end
1344818
def add_command_line_options(add_argument, use_short_options=True):
    
    logger_args = ("--enable-logger",)
    credentials_args = ("--credentials",)
    if use_short_options:
        logger_args += ('-l',)
        credentials_args += ('-c',)
    add_argument(*logger_args, dest='enabled_loggers',
                 action="append", default=[],
                 help="Enable the specified logger.")
    add_argument(*credentials_args, dest='credential_files',
                 action="append", default=[],
                 help="Use the specified credentials module to update "
                 "the values in okcupyd.settings.")
    add_argument('--echo', dest='echo', action='store_true', default=False,
                 help="Echo SQL.")