Esempio n. 1
0
    def replace_installed_refs_remote(self, new_remote_name):
        """Replace remote for all the refs.

        :param str new_remote_name: the remote name which will be used instead of the current one
        """
        install_path = self._installation.get_path()
        install_path = install_path.get_path()  # unpack the Gio.File

        variant_type = VariantType(self.FLATPAK_DEPLOY_DATA_GVARIANT_STRING)

        for ref in self.get_refs_full_format():
            deploy_path = os.path.join(install_path, ref, "active/deploy")

            with open(deploy_path, "rb") as f:
                content = f.read()

            variant = Variant.new_from_bytes(variant_type, Bytes(content),
                                             False)
            children = [
                variant.get_child_value(i) for i in range(variant.n_children())
            ]
            # Replace the origin
            children[0] = Variant('s', new_remote_name)
            new_variant = Variant.new_tuple(*children)
            serialized = new_variant.get_data_as_bytes().get_data()

            with open(deploy_path, "wb") as f:
                f.write(serialized)
Esempio n. 2
0
def _get_object_iface_names(object_path):
    connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
    res_xml = connection.call_sync("org.freedesktop.NetworkManager",
                                   object_path,
                                   "org.freedesktop.DBus.Introspectable",
                                   "Introspect", None, VariantType.new("(s)"),
                                   Gio.DBusCallFlags.NONE, -1, None)
    node_info = Gio.DBusNodeInfo.new_for_xml(res_xml[0])
    return [iface.name for iface in node_info.interfaces]
Esempio n. 3
0
def _get_object_iface_names(object_path):
    connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
    res_xml = connection.call_sync("org.freedesktop.NetworkManager",
                                   object_path,
                                   "org.freedesktop.DBus.Introspectable",
                                   "Introspect",
                                   None,
                                   VariantType.new("(s)"),
                                   Gio.DBusCallFlags.NONE,
                                   -1,
                                   None)
    node_info = Gio.DBusNodeInfo.new_for_xml(res_xml[0])
    return [iface.name for iface in node_info.interfaces]