The Jishaku debug and diagnostic commands.

        This command on its own gives a status brief.
        All other functionality is within its subcommands.
490033
async def jsk(self, ctx: commands.Context):
        

        summary = [
            f"Jishaku v{__version__}, discord.py `{package_version('discord.py')}`, "
            f"`Python {sys.version}` on `{sys.platform}`".replace("\n", ""),
            f"Module was loaded {humanize.naturaltime(self.load_time)}, "
            f"cog was loaded {humanize.naturaltime(self.start_time)}.",
            ""
        ]

        if psutil:
            proc = psutil.Process()

            with proc.oneshot():
                mem = proc.memory_full_info()
                summary.append(f"Using {humanize.naturalsize(mem.rss)} physical memory and "
                               f"{humanize.naturalsize(mem.vms)} virtual memory, "
                               f"{humanize.naturalsize(mem.uss)} of which unique to this process.")

                name = proc.name()
                pid = proc.pid
                thread_count = proc.num_threads()

                summary.append(f"Running on PID {pid} (`{name}`) with {thread_count} thread(s).")

                summary.append("")  # blank line

        cache_summary = f"{len(self.bot.guilds)} guild(s) and {len(self.bot.users)} user(s)"

        if isinstance(self.bot, discord.AutoShardedClient):
            summary.append(f"This bot is automatically sharded and can see {cache_summary}.")
        elif self.bot.shard_count:
            summary.append(f"This bot is manually sharded and can see {cache_summary}.")
        else:
            summary.append(f"This bot is not sharded and can see {cache_summary}.")

        summary.append(f"Average websocket latency: {round(self.bot.latency * 1000, 2)}ms")

        await ctx.send("\n".join(summary))
732836
def show(ctx, service, remote):
    """"""
    logger.debug("running command %s (%s)", ctx.command.name, ctx.params,
                 extra={"command": ctx.command.name, "params": ctx.params})

    home = ctx.obj["HOME"]
    service_path = plugin_utils.get_plugin_path(home, defs.SERVICES, service)

    def collect_local_info(service, service_path):
        logger.debug("loading {} from {}".format(service, service_path))
        service = register_service(service_path)
        try:
            with open(os.path.join(service_path, "requirements.txt"), "r") as fh:
                info["requirements"] = " ".join(fh.readlines())
        except IOError:
            pass
        info["name"] = service.name
        info["label"] = service.label
        info["location"] = service_path

        return info

    def collect_remote_info(service):
        rsession = requests.Session()
        rsession.mount("https://", HTTPAdapter(max_retries=3))

        try:
            r = rsession.get(defs.GITHUB_RAW_URL.format(plugin_type=defs.SERVICES,
                                                        plugin=service, filename="config.json"))
            service_config = r.json()
            info["name"] = service_config[defs.SERVICE][defs.NAME]
            info["label"] = service_config[defs.SERVICE][defs.LABEL]
            info["location"] = defs.GITHUB_URL.format(plugin_type=defs.SERVICES, plugin=info["name"])
        except requests.exceptions.HTTPError as exc:
            logger.debug(str(exc), exc_info=True)
            raise click.ClickException("Cannot find package {}".format(service))
        except requests.exceptions.ConnectionError as exc:
            logger.debug(str(exc), exc_info=True)
            raise click.ClickException("Unable to reach remote repository {}".format(service))

        try:
            r = rsession.get(defs.GITHUB_RAW_URL.format(plugin_type=defs.SERVICES, plugin=info["name"],
                                                        filename="requirements.txt"))
            r.raise_for_status()
            info["requirements"] = " ".join(r.text.split("\n"))
        except requests.exceptions.HTTPError as exc:
            logger.debug(str(exc), exc_info=True)
            info["requirements"] = None
        except requests.exceptions.ConnectionError as exc:
            logger.debug(str(exc), exc_info=True)
            raise click.ClickException("Unable to reach remote repository {}".format(service))

        return info

    info = {"commit_revision": "N/A", "commit_date": "N/A", "requirements": "None"}

    if os.path.exists(service_path):
        info["installed"] = True
        if remote:
            click.secho("[*] Fetching info from online repository")
            info.update(collect_remote_info(service))
        else:
            info.update(collect_local_info(service, service_path))
    else:
        logger.debug("cannot find {} locally".format(service))
        if not remote:
            click.secho("[*] Cannot find service locally, checking online repository")
        info["installed"] = False
        info.update(collect_remote_info(service))
    logger.debug(info)
    click.secho(PKG_INFO_TEMPLATE.format(**info))
895980
Command get_command(final String cmd_name) throws DevFailed {
	Command ret_cmd = null;
	final Vector cmd_list = device_class.get_command_list();
	for (int i = 0; i < cmd_list.size(); i++) {
	    final Command cmd = (Command) cmd_list.elementAt(i);
	    if (cmd.get_name().toLowerCase().equals(cmd_name.toLowerCase())) {
		ret_cmd = cmd;
	    }
	}

	if (ret_cmd == null) {
	    Except.throw_exception("API_CommandNotFound", "Command " + cmd_name + " not found",
		    "DeviceImpl.get_command");
	}

	return ret_cmd;
    }
558664
def ls_cmd(context, before, status):
    """"""
    runs = context.obj['store'].analyses(
        status=status,
        deleted=False,
        before=parse_date(before) if before else None,
    ).limit(30)
    for run_obj in runs:
        if run_obj.status == 'pending':
            message = f"{run_obj.id} | {run_obj.family} [{run_obj.status.upper()}]"
        else:
            message = (f"{run_obj.id} | {run_obj.family} {run_obj.started_at.date()} "
                       f"[{run_obj.type.upper()}/{run_obj.status.upper()}]")
            if run_obj.status == 'running':
                message = click.style(f"{message} - {run_obj.progress * 100}/100", fg='blue')
            elif run_obj.status == 'completed':
                message = click.style(f"{message} - {run_obj.completed_at}", fg='green')
            elif run_obj.status == 'failed':
                message = click.style(message, fg='red')
        print(message)
891781
def status(name, init_system, verbose):
    
    try:
        status = Serv(init_system, verbose=verbose).status(name)
    except ServError as ex:
        sys.exit(ex)
    click.echo(json.dumps(status, indent=4, sort_keys=True))
524626
def debug(version=False):
    """"""
    if version:
        print(__version__)
        return
    print(json.dumps(MANAGE_DICT, indent=2))
344676
def status(host=DEFAULT_HOST, port=DEFAULT_PORT):
    '''
    
    '''
    conn = _connect(host, port)
    try:
        stats = _check_stats(conn)[0]
    except (CommandExecutionError, IndexError):
        return False
    else:
        return {stats[0]: stats[1]}
619562
def status(name, sig=None):
    '''
    
    '''
    if sig:
        # usual way to do by others (debian_service, netbsdservice).
        # XXX probably does not work here (check 'runsv sshd' instead of 'sshd' ?)
        return bool(__salt__['status.pid'](sig))

    svc_path = _service_path(name)
    if not os.path.exists(svc_path):
        # service does not exist
        return False

    # sv return code is not relevant to get a service status.
    # Check its output instead.
    cmd = 'sv status {0}'.format(svc_path)
    try:
        out = __salt__['cmd.run_stdout'](cmd)
        return out.startswith('run: ')
    except Exception:
        # sv (as a command) returned an error
        return False
237023
def bp_commands(self, frame, breakpoint_hits):
        """"""
        # Handle multiple breakpoints on the same line (issue 14789)
        effective_bp_list, temporaries = breakpoint_hits
        silent = True
        doprompt = False
        atleast_one_cmd = False
        for bp in effective_bp_list:
            if bp in self.commands:
                if not atleast_one_cmd:
                    atleast_one_cmd = True
                    self.setup(frame, None)
                lastcmd_back = self.lastcmd
                for line in self.commands[bp]:
                    self.onecmd(line)
                self.lastcmd = lastcmd_back
                if not self.commands_silent[bp]:
                    silent = False
                if self.commands_doprompt[bp]:
                    doprompt = True
        # Delete the temporary breakpoints.
        tmp_to_delete = ' '.join(str(bp) for bp in temporaries)
        if tmp_to_delete:
            self.do_clear(tmp_to_delete)

        if atleast_one_cmd:
            return doprompt, silent
        return None
79975
def basic_status_and_output(messages)
      status =
        if messages.any? { |message| message.type == :error }
          :fail
        elsif messages.any? { |message| message.type == :warning }
          :warn
        else
          :pass
        end

      output = ''
      if messages.any?
        output += messages.join("\n") + "\n"
      end

      [status, output]
    end
28644
def query_apsupsd_status():
    
    import subprocess
    output = {}
    try:
        apc_status = subprocess.check_output("/sbin/apcaccess")
    except:
        return None
    output['timestamp'] = time()
    for line in apc_status.split('\n'):
        (key, spl, val) = line.partition(': ')
        key = key.rstrip().upper()
        val = val.strip()
        val = val.split(' ')[0]
        if key == 'STATUS':
            output[key] = True if val.upper() == 'ONLINE' else False
        elif key in ['LINEV', 'BATTV', 'BCHARGE', 'TIMELEFT', 'LOADPCT']:
            output[key] = float(val)

    return output
724418
def command_exit(self, details):
        
        log = self._params.get('log', self._discard)
        pid = self._key
        status = details
        why = statusfmt(status)
        if status:
            log.warning("pid %d for %s(%s) %s", pid, self._name, self._handler_arg, why)
        else:
            log.info("pid %d for %s(%s) %s", pid, self._name, self._handler_arg, why)
365736
private void determineCommand() {
        command = null;
        commandStr = null;

        boolean tooManyCommands = false;
        for (Command c : Command.values()) {
            final String alias = c.getAlias();
            if (hasOption(alias)) {
                if (c == Command.HELP) {
                    // `--help` can be a command or just a long option for another command.
                    help = true;
                } else if (command == null) {
                    // Found a command option
                    command = c;
                    commandStr = alias;
                } else {
                    tooManyCommands = true;
                }
            }
        }

        if (tooManyCommands) {
            command = null;
            commandStr = null;

            if (!help) {
                reportable.error(format(
                        "You must specify only one command (%s).%n",
                        showCommandAliases()));
                printHelp(true);
            }
        }
        if (help && command == null) {
            // `--help` is considered as the command if no other command is provided.
            command = Command.HELP;
            commandStr = command.getAlias();

        } else if (command == null) {
        	// Print usage if no commands were specified
        	printUsage();
        	reportable.error("\n");
            reportable
                    .error("No command option given. Please specify one of:  "
                            + showCommandAliases());
            end();
        }
    }
1292960
@SuppressFBWarnings("DM_EXIT")
    public static void showHelp(TextUICommandLine commandLine) {
        showSynopsis();
        ShowHelp.showGeneralOptions();
        FindBugs.showCommandLineOptions(commandLine);
        System.exit(1);
    }
1260850
def cmd_gimbal_status(self, args):
        ''''''
        master = self.master
        if 'GIMBAL_REPORT' in master.messages:
            print(master.messages['GIMBAL_REPORT'])
        else:
            print("No GIMBAL_REPORT messages")
750085
def command(self):
        
        msg = self.gui.status_message
        n = len(msg)
        n_cur = len(self.cursor)
        return msg[:n - n_cur]
428713
def log_status(cmd, message, verbose, color = false)
      return unless verbose

      cmd = cmd.to_s.rjust(12)
      if color
        i = cmd.index(/[a-z]/)
        cmd = cmd[0...i] + decorate(cmd[i..-1], color)
      end

      message = "#{cmd}  #{message}"
      message += "\n" unless message.end_with?("\n")

      @output.print(message)
      @output.flush
    end