晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /usr/share/fwupd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/fwupd/simple_client.py
#!/usr/libexec/platform-python
# SPDX-License-Identifier: LGPL-2.1+
"""A simple fwupd frontend"""
import sys
import os
import gi
from gi.repository import GLib

gi.require_version("Fwupd", "2.0")
from gi.repository import Fwupd  # pylint: disable=wrong-import-position


class Progress:
    """Class to track the signal changes of progress events"""

    def __init__(self):
        self.device = None
        self.status = None
        self.percent = 0
        self.erase = 0

    def device_changed(self, new_device):
        """Indicate new device string to track"""
        if self.device != new_device:
            self.device = new_device
            print("\nUpdating %s" % self.device)

    def status_changed(self, percent, status):
        """Indicate new status string or % complete to track"""
        if self.status != status or self.percent != percent:
            for i in range(0, self.erase):
                sys.stdout.write("\b \b")
            self.status = status
            self.percent = percent
            status_str = "["
            for i in range(0, 50):
                if i < percent / 2:
                    status_str += "*"
                else:
                    status_str += " "
            status_str += "] %d%% %s" % (percent, status)
            self.erase = len(status_str)
            sys.stdout.write(status_str)
            sys.stdout.flush()
            if "idle" in status:
                sys.stdout.write("\n")


def parse_args():
    """Parse arguments for this client"""
    import argparse

    parser = argparse.ArgumentParser(description="Interact with fwupd daemon")
    parser.add_argument(
        "--allow-older",
        action="store_true",
        help="Install older payloads(default False)",
    )
    parser.add_argument(
        "--allow-reinstall",
        action="store_true",
        help="Reinstall payloads(default False)",
    )
    parser.add_argument(
        "command",
        choices=["get-devices", "get-details", "install", "refresh"],
        help="What to do",
    )
    parser.add_argument("cab", nargs="?", help="CAB file")
    parser.add_argument("deviceid", nargs="?", help="DeviceID to operate on(optional)")
    args = parser.parse_args()
    return args


def refresh(client):
    """Uses fwupd client to refresh metadata"""
    remotes = client.get_remotes()
    client.set_user_agent_for_package("simple_client", "1.7.8")
    for remote in remotes:
        if not remote.get_enabled():
            continue
        if remote.get_kind() != Fwupd.RemoteKind.DOWNLOAD:
            continue
        client.refresh_remote(remote)


def get_devices(client):
    """Use fwupd client to fetch devices"""
    devices = client.get_devices()
    for item in devices:
        print(item.to_string())


def get_details(client, cab):
    """Use fwupd client to fetch details for a CAB file"""
    devices = client.get_details(cab, None)
    for device in devices:
        print(device.to_string())


def status_changed(client, spec, progress):  # pylint: disable=unused-argument
    """Signal emitted by fwupd daemon indicating status changed"""
    progress.status_changed(
        client.get_percentage(), Fwupd.status_to_string(client.get_status())
    )


def device_changed(client, device, progress):  # pylint: disable=unused-argument
    """Signal emitted by fwupd daemon indicating active device changed"""
    progress.device_changed(device.get_name())


def install(client, cab, target, older, reinstall):
    """Use fwupd client to install CAB file to applicable devices"""
    # FWUPD_DEVICE_ID_ANY
    if not target:
        target = "*"
    flags = Fwupd.InstallFlags.NONE
    if older:
        flags |= Fwupd.InstallFlags.ALLOW_OLDER
    if reinstall:
        flags |= Fwupd.InstallFlags.ALLOW_REINSTALL
    progress = Progress()
    parent = super(client.__class__, client)
    parent.connect("device-changed", device_changed, progress)
    parent.connect("notify::percentage", status_changed, progress)
    parent.connect("notify::status", status_changed, progress)
    try:
        client.install(target, cab, flags, None)
    except GLib.Error as glib_err:  # pylint: disable=catching-non-exception
        progress.status_changed(0, "idle")
        print("%s" % glib_err)
        sys.exit(1)
    print("\n")


def check_exists(cab):
    """Check that CAB file exists"""
    if not cab:
        print("Need to specify payload")
        sys.exit(1)
    if not os.path.isfile(cab):
        print("%s doesn't exist or isn't a file" % cab)
        sys.exit(1)


if __name__ == "__main__":
    ARGS = parse_args()
    CLIENT = Fwupd.Client()

    if ARGS.command == "get-devices":
        get_devices(CLIENT)
    elif ARGS.command == "get-details":
        check_exists(ARGS.cab)
        get_details(CLIENT, ARGS.cab)
    elif ARGS.command == "refresh":
        refresh(CLIENT)
    elif ARGS.command == "install":
        check_exists(ARGS.cab)
        install(CLIENT, ARGS.cab, ARGS.deviceid, ARGS.allow_older, ARGS.allow_reinstall)

haha - 2025