python: use gi.require_version() in generate-setting-docs.py and examples
gi now emits a warning when not loading a specific library version [1]: ./generate-setting-docs.py:21: PyGIWarning: NM was imported without specifying a version first. Use gi.require_version(NM, 1.0) before import to ensure that the right version gets loaded. from gi.repository import NM, GObject Seems require_version() is reasonably old to just always use it without breaking on older versions [2]. [1] Related: https://bugzilla.gnome.org/show_bug.cgi?id=727379 [2] https://git.gnome.org/browse/pygobject/commit/?id=76758efb6579752237a0dc4d56cf9518de6c6e55
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
|
||||
#
|
||||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
import sys, uuid
|
||||
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import NM
|
||||
|
||||
# suported connection types
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
#
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
#
|
||||
|
@@ -21,6 +21,8 @@
|
||||
|
||||
# This example lists currently active connections
|
||||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
# This example shows how to get a list of LLDP neighbors for a given interface.
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#
|
||||
|
||||
import sys, socket
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
#
|
||||
|
@@ -20,6 +20,8 @@
|
||||
# Copyright 2012 - 2014 Red Hat, Inc.
|
||||
#
|
||||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import NM
|
||||
|
||||
# This example asks settings service for all configured connections.
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#
|
||||
|
||||
import locale
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import NM
|
||||
|
||||
#
|
||||
|
@@ -27,6 +27,8 @@
|
||||
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
|
||||
#
|
||||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
import sys, socket
|
||||
|
||||
|
Reference in New Issue
Block a user