diff options
Diffstat (limited to 'examples/python/gi')
-rw-r--r-- | examples/python/gi/Makefile.am | 9 | ||||
-rw-r--r-- | examples/python/gi/Makefile.in | 582 | ||||
-rwxr-xr-x | examples/python/gi/add_connection.py | 101 | ||||
-rwxr-xr-x | examples/python/gi/device-state-ip4config.py | 64 | ||||
-rwxr-xr-x | examples/python/gi/firewall-zone.py | 87 | ||||
-rwxr-xr-x | examples/python/gi/get-active-connections.py | 34 | ||||
-rwxr-xr-x | examples/python/gi/get_ips.py | 163 | ||||
-rwxr-xr-x | examples/python/gi/list-connections.py | 50 | ||||
-rwxr-xr-x | examples/python/gi/show-wifi-networks.py | 73 | ||||
-rwxr-xr-x | examples/python/gi/update-ip4-method.py | 96 |
10 files changed, 1259 insertions, 0 deletions
diff --git a/examples/python/gi/Makefile.am b/examples/python/gi/Makefile.am new file mode 100644 index 000000000..dcf2dff09 --- /dev/null +++ b/examples/python/gi/Makefile.am @@ -0,0 +1,9 @@ +EXTRA_DIST = \ + list-connections.py \ + device-state-ip4config.py \ + firewall-zone.py \ + show-wifi-networks.py \ + get_ips.py \ + add_connection.py \ + get-active-connections.py \ + update-ip4-method.py diff --git a/examples/python/gi/Makefile.in b/examples/python/gi/Makefile.in new file mode 100644 index 000000000..8ea13b18d --- /dev/null +++ b/examples/python/gi/Makefile.in @@ -0,0 +1,582 @@ +# Makefile.in generated by automake 1.13.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = examples/python/gi +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gnome-code-coverage.m4 \ + $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CKDB_PATH = @CKDB_PATH@ +CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ +CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ +CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DHCLIENT_PATH = @DHCLIENT_PATH@ +DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ +DLLTOOL = @DLLTOOL@ +DNSMASQ_PATH = @DNSMASQ_PATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ +GNUTLS_LIBS = @GNUTLS_LIBS@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ +KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDL = @LIBDL@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ +LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_LIBS = @LIBNL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ +MM_GLIB_LIBS = @MM_GLIB_LIBS@ +MOC = @MOC@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ +NM_VERSION = @NM_VERSION@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ +SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ +SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ +SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ +SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ +SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ +VAPIGEN = @VAPIGEN@ +VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ +VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nmbinary = @nmbinary@ +nmconfdir = @nmconfdir@ +nmdatadir = @nmdatadir@ +nmrundir = @nmrundir@ +nmstatedir = @nmstatedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +subdirs = @subdirs@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_dhclient = @with_dhclient@ +with_dhcpcd = @with_dhcpcd@ +with_netconfig = @with_netconfig@ +with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ +EXTRA_DIST = \ + list-connections.py \ + device-state-ip4config.py \ + firewall-zone.py \ + show-wifi-networks.py \ + get_ips.py \ + add_connection.py \ + get-active-connections.py \ + update-ip4-method.py + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/python/gi/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/python/gi/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/examples/python/gi/add_connection.py b/examples/python/gi/add_connection.py new file mode 100755 index 000000000..76c2e94e6 --- /dev/null +++ b/examples/python/gi/add_connection.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# +# This example shows how to add a new NM connection profile. +# The code uses libnm-util (NetworkManager) and libnm-glib (NMClient) +# via GObject Introspection. +# +# Documentation links: +# https://developer.gnome.org/libnm-glib/0.9/ +# https://developer.gnome.org/libnm-util/0.9/ +# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# + +from gi.repository import GLib, NetworkManager, NMClient +import sys, uuid + +main_loop = None + +def print_values(setting, key, value, flags, data): + print " %s.%s: %s" % (setting.get_name(), key, value) + +# create an Ethernet connection and return it +def create_profile(name): + profile = NetworkManager.Connection.new() + s_con = NetworkManager.SettingConnection.new() + s_con.set_property(NetworkManager.SETTING_CONNECTION_ID, name) + s_con.set_property(NetworkManager.SETTING_CONNECTION_UUID, str(uuid.uuid4())) + s_con.set_property(NetworkManager.SETTING_CONNECTION_TYPE, "802-3-ethernet") + + s_wired = NetworkManager.SettingWired.new() + + s_ip4 = NetworkManager.SettingIP4Config.new() + s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, "auto") + + s_ip6 = NetworkManager.SettingIP6Config.new() + s_ip6.set_property(NetworkManager.SETTING_IP6_CONFIG_METHOD, "auto") + + profile.add_setting(s_con) + profile.add_setting(s_ip4) + profile.add_setting(s_ip6) + profile.add_setting(s_wired) + + print("Created connection profile:") + profile.for_each_setting_value(print_values, None) + + return profile + +# callback function +def added_cb(settings, con, error, data): + if error is (None): + print("The connection profile has been succesfully added to NetworkManager.") + else: + print(error) + main_loop.quit() + +if __name__ == "__main__": + # parse arguments + persistent = False + if len(sys.argv) != 2 and len(sys.argv) != 3: + sys.exit('Usage: %s <connection name> [persistent]' % sys.argv[0]) + if len(sys.argv) == 3: + if sys.argv[2] in "persistent" and sys.argv[2][:1] == "p": + persistent = True + else: + sys.exit('Usage: %s <connection name> [persistent]' % sys.argv[0]) + profile_name = sys.argv[1] + + main_loop = GLib.MainLoop() + + # create RemoteSettings object + settings = NMClient.RemoteSettings.new(None); + + # create a connection profile for NM + con = create_profile(profile_name) + + # send the connection to NM + if persistent: + settings.add_connection(con, added_cb, None) + else: + settings.add_connection_unsaved(con, added_cb, None) + + main_loop.run() + diff --git a/examples/python/gi/device-state-ip4config.py b/examples/python/gi/device-state-ip4config.py new file mode 100755 index 000000000..be19b9966 --- /dev/null +++ b/examples/python/gi/device-state-ip4config.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# vim: ft=python ts=4 sts=4 sw=4 et ai +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2012 Red Hat, Inc. +# + +import sys +from gi.repository import GLib, NetworkManager, NMClient + +# +# This example shows how to get NMIP4Config from NMDevice after it is activated. +# +# We listen to notify::ip4-config glib signal. This signal is trigered by D-Bus +# PropertiesChanged for IP4Config that comes after StateChanged for NMDevice. +# + +main_loop = None + +def do_notify(self, property): + print "notify: %s" % property + ip4cfg = self.get_ip4_config() + if ip4cfg is not None: + print "ip4-config: %s" % ip4cfg.get_path() + main_loop.quit() + +def state_changed(obj, arg1, arg2, arg3): + print "State changed: New: %d, Old: %d, Reason: %d" % (arg1, arg2, arg3) + # Device is connected + if arg1 == 100: + obj.connect('notify::ip4-config', do_notify) + + +if __name__ == "__main__": + if len(sys.argv) != 2: + sys.exit('Usage: %s <interface>' % sys.argv[0]) + dev_iface = sys.argv[1] + + c = NMClient.Client.new() + dev = c.get_device_by_iface(dev_iface) + if dev is None: + sys.exit('Device \'%s\' not found' % dev_iface) + print "Device: %s - %s" % (dev_iface, dev.get_device_type().value_name) + print "---------------------------------------" + + dev.connect('state-changed', state_changed) + main_loop = GLib.MainLoop() + main_loop.run() + diff --git a/examples/python/gi/firewall-zone.py b/examples/python/gi/firewall-zone.py new file mode 100755 index 000000000..5e5eea919 --- /dev/null +++ b/examples/python/gi/firewall-zone.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# vim: ft=python ts=4 sts=4 sw=4 et ai +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2013 Red Hat, Inc. +# + +import sys +from gi.repository import GLib, NetworkManager, NMClient + +# +# This example demonstrates how to get and change firewall zone in a +# connection. It uses GObject Introspection instead of direct D-Bus calls. +# 'zone' is a property of 'connection' setting in a connection. You can't +# get/set individual properties directly. Rather you ask for the whole +# connection, change a property and update the connection back into +# NetworkManager. +# If you used D-Bus calls, you would call GetSettings() and then Update(). +# +# Links: +# https://developer.gnome.org/libnm-glib/0.9/ +# https://wiki.gnome.org/GObjectIntrospection +# https://wiki.gnome.org/PyGObject +# + +main_loop = None + +def connection_saved(connection, error, data): + print ("Connection '%s' saved.") % (connection.get_id()) + main_loop.quit() + +def connections_read(settings, data): + con_name = sys.argv[1] + if len(sys.argv) == 3: + new_zone = sys.argv[2] + else: + new_zone = None + + found = False + connections = settings.list_connections() + for c in connections: + if c.get_id() == con_name or c.get_uuid() == con_name: + found = True + s_con = c.get_setting_connection() + if new_zone is None: + zone = s_con.get_zone() + if zone is not None: + print("'%s' zone is '%s'") % (c.get_id(), zone) + else: + print("'%s' zone is empty") % (c.get_id()) + main_loop.quit() + else: + s_con.set_property("zone", new_zone) + c.commit_changes(connection_saved, None) + print("'%s' zone set to '%s'") % (c.get_id(), new_zone) + break + if not found: + print ("Error: connection '%s' not found.") % (con_name) + main_loop.quit() + + +if __name__ == "__main__": + if len(sys.argv) != 2 and len(sys.argv) != 3: + sys.exit('Usage: %s <connection name or UUID> [new zone]' % sys.argv[0]) + + main_loop = GLib.MainLoop() + settings = NMClient.RemoteSettings.new(None); + + # Connections are read asynchronously, so we have to wait for the + # 'settings' object to tell us that all connections have been read. + settings.connect("connections-read", connections_read, None) + main_loop.run() + diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py new file mode 100755 index 000000000..13f0b0310 --- /dev/null +++ b/examples/python/gi/get-active-connections.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# vim: ft=python ts=4 sts=4 sw=4 et ai +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# This example lists currently active connections + +from gi.repository import GLib, NMClient + +if __name__ == "__main__": + client = NMClient.Client.new() + acons = client.get_active_connections() + for ac in acons: + print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type()) + if len(acons) == 0: + print "No active connections" + + diff --git a/examples/python/gi/get_ips.py b/examples/python/gi/get_ips.py new file mode 100755 index 000000000..6903b6de2 --- /dev/null +++ b/examples/python/gi/get_ips.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python +# +# vim: ft=python ts=4 sts=4 sw=4 et ai +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +import sys, socket, struct +from gi.repository import GLib, NetworkManager, NMClient + +# +# This example shows how to get addresses, routes and DNS information +# from NMIP4Config and NMIP6Config (got out of NMDevice) +# + +def show_addresses(self, family): + if (family == socket.AF_INET): + ip_cfg = self.get_ip4_config() + else: + ip_cfg = self.get_ip6_config() + + if ip_cfg is None: + print("None") + return + + nm_addresses = ip_cfg.get_addresses() + if len(nm_addresses) == 0: + print("None") + return + + for nm_address in nm_addresses: + addr = nm_address.get_address() + prefix = nm_address.get_prefix() + gateway = nm_address.get_gateway() + + if (family == socket.AF_INET): + addr_struct = struct.pack("=I", addr) + gateway_struct = struct.pack("=I", gateway) + else: + addr_struct = addr + gateway_struct = gateway + print("%s/%d %s") % (socket.inet_ntop(family, addr_struct), + prefix, + socket.inet_ntop(family, gateway_struct)) + + +def show_routes(self, family): + if (family == socket.AF_INET): + ip_cfg = self.get_ip4_config() + else: + ip_cfg = self.get_ip6_config() + + if ip_cfg is None: + print("None") + return + + nm_routes = ip_cfg.get_routes() + if len(nm_routes) == 0: + print("None") + return + + for nm_route in nm_routes: + dest = nm_route.get_dest() + prefix = nm_route.get_prefix() + next_hop = nm_route.get_next_hop() + metric = nm_route.get_metric() + + if (family == socket.AF_INET): + dest_struct = struct.pack("=I", dest) + next_hop_struct = struct.pack("=I", next_hop) + else: + dest_struct = dest + next_hop_struct = next_hop + print("%s/%d %s %d") % (socket.inet_ntop(family, dest_struct), + prefix, + socket.inet_ntop(family, next_hop_struct), + metric) + + +def show_dns(self, family): + if (family == socket.AF_INET): + ip_cfg = self.get_ip4_config() + else: + ip_cfg = self.get_ip6_config() + + if ip_cfg is None: + print("None") + return + + if (family == socket.AF_INET): + print ("Domains: %s") % (ip_cfg.get_domains()) + print ("Searches: %s") % (ip_cfg.get_searches()) + print("Nameservers:") + nameservers = ip_cfg.get_nameservers() + for dns in nameservers: + print socket.inet_ntop(family, struct.pack("=I", dns)) + else: + print ("Domains: %s") % (ip_cfg.get_domains()) + print ("Searches: %s") % (ip_cfg.get_searches()) + print("Nameservers:") + num = ip_cfg.get_num_nameservers() + for i in range(0,num): + dns = ip_cfg.get_nameserver(i) + print socket.inet_ntop(family, dns) + + +if __name__ == "__main__": + if len(sys.argv) != 2: + sys.exit('Usage: %s <interface>' % sys.argv[0]) + dev_iface = sys.argv[1] + + c = NMClient.Client.new() + dev = c.get_device_by_iface(dev_iface) + if dev is None: + sys.exit('Device \'%s\' not found' % dev_iface) + print "Device: %s - %s" % (dev_iface, dev.get_device_type().value_name) + print "---------------------------------------" + + print("IPv4 addresses:") + print("---------------") + show_addresses(dev, socket.AF_INET) + print + + print("IPv4 routes:") + print("------------") + show_routes(dev, socket.AF_INET) + print + + print "IPv6 addresses:" + print("---------------") + show_addresses(dev, socket.AF_INET6) + print + + print "IPv6 routes:" + print("------------") + show_routes(dev, socket.AF_INET6) + print + + print "IPv4 DNS:" + print("------------") + show_dns(dev, socket.AF_INET) + print + + print "IPv6 DNS:" + print("------------") + show_dns(dev, socket.AF_INET6) + print + diff --git a/examples/python/gi/list-connections.py b/examples/python/gi/list-connections.py new file mode 100755 index 000000000..b6452d35a --- /dev/null +++ b/examples/python/gi/list-connections.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2012 Red Hat, Inc. +# + +from gi.repository import GLib, NetworkManager, NMClient + +# This example asks settings service for all configured connections. +# Unfortunately, at this time since libnm-glib still makes heavy use of +# GValue and GHashTable (rather than GVariant), libnm-glib isn't fully +# usable from GObject Introspection-ready languages. Most functions will +# work fine, but e. g. nm_connection_to_hash() causes assertion failures. + +main_loop = None + +def print_values(setting, key, value, flags, data): + print " %s.%s: %s" % (setting.get_name(), key, value) + +def connections_read(settings): + connections = settings.list_connections() + for c in connections: + print "--- %s : %s" % (c.get_id(), c.get_path()) + c.for_each_setting_value(print_values, None) + print "\n" + main_loop.quit() + +if __name__ == "__main__": + main_loop = GLib.MainLoop() + settings = NMClient.RemoteSettings.new(None); + + # connections are read asynchronously, so we need to wait for the + # settings object to tell us that it's read all connections + settings.connect("connections-read", connections_read) + main_loop.run() + diff --git a/examples/python/gi/show-wifi-networks.py b/examples/python/gi/show-wifi-networks.py new file mode 100755 index 000000000..9d9e34718 --- /dev/null +++ b/examples/python/gi/show-wifi-networks.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# coding=utf-8 +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# vim: ft=python ts=4 sts=4 sw=4 et ai +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2013 Red Hat, Inc. +# + +from gi.repository import NetworkManager, NMClient + +# +# This example lists Wi-Fi access points NetworkManager scanned on Wi-Fi devices. +# It calls libnm-glib functions using GObject introspection. +# +# Note the second line of the file: coding=utf-8 +# It is necessary because we use unicode characters and python would produce +# an error without it: http://www.python.org/dev/peps/pep-0263/ +# + +signal_bars = { + 0 : "____", + 1 : "▂___", + 2 : "▂▄__", + 3 : "▂▄▆_", + 4 : "▂▄▆█" +} + +def clamp(value, minvalue, maxvalue): + return max(minvalue, min(value, maxvalue)) + +def print_device_info(device): + active_ap = dev.get_active_access_point() + ssid = None + if active_ap is not None: + ssid = active_ap.get_ssid() + info = "Device: %s | Driver: %s | Active AP: %s" % (dev.get_iface(), dev.get_driver(), ssid) + print info + print '=' * len(info) + +def print_ap_info(ap): + strength = ap.get_strength() + frequency = ap.get_frequency() + print "SSID: %s" % (ap.get_ssid()) + print "BSSID: %s" % (ap.get_bssid()) + print "Frequency: %s" % (frequency) + print "Channel: %s" % (NetworkManager.utils_wifi_freq_to_channel(frequency)) + print "Strength: %s %s%%" % (signal_bars[(clamp(strength-5, 0, 99)+24)/25], strength) + print + +if __name__ == "__main__": + nmc = NMClient.Client.new() + devs = nmc.get_devices() + + for dev in devs: + if dev.get_device_type() == NetworkManager.DeviceType.WIFI: + print_device_info(dev) + for ap in dev.get_access_points(): + print_ap_info(ap) + diff --git a/examples/python/gi/update-ip4-method.py b/examples/python/gi/update-ip4-method.py new file mode 100755 index 000000000..2fe12693b --- /dev/null +++ b/examples/python/gi/update-ip4-method.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# +# This example updates a connection's IPv4 method with the Update() method +# using the libnm-glib GObject-based convenience APIs. +# +# Configuration settings are described at +# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# + +from gi.repository import GLib, NetworkManager, NMClient +import sys, struct, socket + +def ip_to_int(ip_string): + return struct.unpack("=I", socket.inet_aton(ip_string))[0] + +# callback function +def commit_cb(connection, error, data): + if error is (None): + print("The connection profile has been updated.") + else: + print(error) + main_loop.quit() + +def connections_read_cb(settings, data): + uuid, method, args = data + + all_connections = settings.list_connections() + for c in all_connections: + if c.get_uuid() != uuid: + continue + + # add IPv4 setting if it doesn't yet exist + s_ip4 = c.get_setting_ip4_config() + if not s_ip4: + s_ip4 = NetworkManager.SettingIP4Config.new() + c.add_setting(s_ip4) + + # set the method and change properties + s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, method) + if method == "auto": + # remove addresses + s_ip4.clear_addresses() + elif method == "manual": + # Add the static IP address, prefix, and (optional) gateway + addr = NetworkManager.IP4Address.new() + addr.set_address(ip_to_int(sys.argv[3])) + addr.set_prefix(int(sys.argv[4])) + if len(sys.argv) == 6: + addr.set_gateway(ip_to_int(sys.argv[5])) + s_ip4.add_address(addr) + + c.commit_changes(commit_cb, None) + +if __name__ == "__main__": + # parse and validate arguments + if len(sys.argv) < 3: + print "Usage: %s <uuid> <auto|static> [address prefix gateway]" % sys.argv[0] + sys.exit(1) + + method = sys.argv[2] + if method == "static" and len(sys.argv) < 5: + print "Usage: %s %s static address prefix [gateway]" % (sys.argv[0], sys.argv[1]) + sys.exit(1) + + # Convert method to NM method + if method == "static": + method = "manual" + + main_loop = GLib.MainLoop() + + # create RemoteSettings object and attach to the "connections-read" signal + # to wait for connections to be loaded asynchronously + settings = NMClient.RemoteSettings.new(None) + settings.connect('connections-read', connections_read_cb, (sys.argv[1], method, sys.argv)) + + main_loop.run() + |