[Python] How to provide 4th argument for NM.SecretAgentOldGetSecretsFunc in NM 1.0 when...

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Network Manager (NM 1.0) from PyGObject to create a widget that can show and connect to a network. I created a subclass of NM.SecretAgentOld to provide passwords to NM, basically I just overwrite the virtual method

    def do_get_secrets(
    self,
    connection,
    connection_path,
    setting_name,
    hints,
    flags,
    callback,
    *callback_data
    ):

    <after retrieving the password>

    <convert password to GLib.Variant>

    callback(self, connection, password, None)


    And after retrieving the password I simply call the callback provided by NM. However callback (or more specifically NM.SecretAgentOldGetSecretsFunc type) takes 4th argument as a GLib.Error in case of any error. But it doesn't mention what to use when there's no error and using None raises a type error (it says argument 3 doesn't allow `None` type).

    How can I fix this?

    N.B: The code from the official Network Manager's python example secret-agent.py (gitlab) also shows type error.

    Continue reading...

Compartilhe esta Página