Comment 1 for bug 1887903

Revision history for this message
Pierre Equoy (pieq) wrote :

A better solution to communicate with snapd would be to use, as explained by jamesh on the snapcraft forum a long time ago[1].

It requires python3-gi and gir1.2-snapd-1 packages.

Then (see Snapd Gi doc for more info[2]):

import gi
gi.require_version('Snapd', '1')
from gi.repository import Snapd
c = Snapd.Client()
active_snaps_flag = Snapd.GetSnapsFlags(0)
for snap in c.get_snaps_sync(Snapd.GetSnapsFlags(0), None):
    print(snap.props.name, snap.props.devmode)

[1] https://forum.snapcraft.io/t/how-to-communicate-with-run-snapd-socket-using-python/6432/4
[2] https://lazka.github.io/pgi-docs/#Snapd-1