trivial: simple_client: add a refresh metadata function

This commit is contained in:
Mario Limonciello 2020-11-20 13:47:25 -06:00 committed by Richard Hughes
parent 88dc597125
commit a13ba4e8a1
2 changed files with 22 additions and 3 deletions

View File

@ -1,10 +1,17 @@
if get_option('firmware-packager')
install_data('firmware_packager.py',
install_dir : 'share/fwupd')
install_data('simple_client.py',
install_dir : 'share/fwupd')
install_data('add_capsule_header.py',
install_dir : 'share/fwupd')
install_data('install_dell_bios_exe.py',
install_dir : 'share/fwupd')
con2 = configuration_data()
con2.set('FWUPD_VERSION', fwupd_version)
configure_file(
input : 'simple_client.py',
output : 'simple_client.py',
configuration : con2,
install: true,
install_dir: 'share/fwupd',
)
endif

View File

@ -62,13 +62,23 @@ def parse_args():
help="Reinstall payloads(default False)",
)
parser.add_argument(
"command", choices=["get-devices", "get-details", "install"], help="What to do"
"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", "@FWUPD_VERSION@")
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"""
@ -140,6 +150,8 @@ if __name__ == '__main__':
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)