def run_function(
    client: CommandClient, funcname: str, args: list[str], kwargs: dict[str, str]
) -> str:
    "Run command with specified args on given object."
    try:
        ret = client.call(funcname, *args, **kwargs, lifted=True)
    except SelectError:
        print("error: Sorry no function ", funcname)
        sys.exit(1)
    except CommandError as e:
        print(f"error: Command '{funcname}' returned error: {str(e)}")
        sys.exit(1)
    except CommandException as e:
        print(f"error: Sorry cannot run function '{funcname}' with arguments {args}: {str(e)}")
        sys.exit(1)

    return ret
Run command with specified args on given object.
libqtile/scripts/cmd_obj.py