python-networkmanager-0.9.10/0000775000175000017500000000000012211043706016724 5ustar dennisdennis00000000000000python-networkmanager-0.9.10/PKG-INFO0000664000175000017500000000112412211043706020017 0ustar dennisdennis00000000000000Metadata-Version: 1.1 Name: python-networkmanager Version: 0.9.10 Summary: Easy communication with NetworkManager Home-page: http://github.com/seveas/python-networkmanager Author: Dennis Kaarsemaker Author-email: dennis@kaarsemaker.net License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Topic :: System :: Networking python-networkmanager-0.9.10/docs/0000775000175000017500000000000012211043706017654 5ustar dennisdennis00000000000000python-networkmanager-0.9.10/docs/conf.py0000664000175000017500000001567112211043626021166 0ustar dennisdennis00000000000000# -*- coding: utf-8 -*- # # python-networkmanager documentation build configuration file, created by # sphinx-quickstart on Fri Nov 4 00:28:50 2011. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'python-networkmanager' copyright = u'2011-2013, Dennis Kaarsemaker' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.9' # The full version, including alpha/beta/rc tags. release = '0.9.10' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'python-networkmanagerdoc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'python-networkmanager.tex', u'python-networkmanager Documentation', u'Dennis Kaarsemaker', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'python-networkmanager', u'python-networkmanager Documentation', [u'Dennis Kaarsemaker'], 1) ] python-networkmanager-0.9.10/docs/index.rst0000664000175000017500000001334212123652075021527 0ustar dennisdennis00000000000000Python API to talk to NetworkManager ==================================== NetworkManager provides a detailed and capable D-Bus interface on the system bus. You can use this interface to query NetworkManager about the overall state of the network and details of network devices like current IP addresses or DHCP options, and to activate and deactivate network connections. python-networkmanager takes this D-Bus interface and wraps D-Bus interfaces in classes and D-Bus properties in python properties. It also provides a command-line utility to inspect the configuration and (de-)activate connections. The :mod:`NetworkManager` module -------------------------------- .. module:: NetworkManager :platform: Linux systems with NetworkManager 0.9.x :synopsis: Talk to NetworkManager from python All the code is contained in one module: :mod:`NetworkManager`. Using it is as simple as you think it is: .. code-block:: py >>> import NetworkManager >>> NetworkManager.NetworkManager.Version '0.9.6.0' NetworkManager exposes a lot of information via D-Bus and also allows full control of network settings. The full D-Bus API can be found on `NetworkManager project website`_. All interfaces listed there have been wrapped in classes as listed below. With a few exceptions, they behave exactly like the D-Bus methods. These exceptions are for convenience and limited to this list: * IP addresses are returned as strings of the form :data:`1.2.3.4` instead of network byte ordered integers. * Route metrics are returned in host byte order, so you can use them as integers. * Mac addresses and BSSIDs are always returned as strings of the form :data:`00:11:22:33:44:55` instead of byte sequences. * Wireless SSID's are returned as strings instead of byte sequences. They will be decoded as UTF-8 data, so using any other encoding for your SSID will result in errors. .. class:: NMDbusInterface This is the base class for all interface wrappers. It adds a few useful features to standard D-Bus interfaces: * All D-Bus properties are exposed as python properties * Return values are automatically converted to python basic types (so no more :data:`dbus.String`, but simple :data:`str` (python 3) or :data:`unicode` (python 2)) * Object paths in return values are automatically replaced with proxy objects, so you don't need to do that manually * ...and vice versa when sending * And also when receiving signals .. function:: const(prefix, value) Many of NetworkManagers D-Bus methods expect or return numeric constants, for which there are enums in the C source code. These constants, such as :data:`NM_STATE_CONNECTED_GLOBAL`, can all be found in the :mod:`NetworkManager` module as well. The :func:`const` function can help you translate them to text. For example: .. code-block:: py >>> NetworkManager.const('state', 40) 'connecting' >>> NetworkManager.const('device_type', 2) 'wifi' .. _`NetworkManager project website`: projects.gnome.org/NetworkManager/developers/api/09/spec.html List of classes --------------- .. class:: NetworkManager This class represents the :data:`org.freedesktop.NetworkManager` interface. Note that :data:`NetworkManager.NetworkManager` actually is the singleton instance of this class. .. class:: Settings This class represents the :data:`org.freedesktop.NetworkManager.Settings` interface. Note that :data:`NetworkManager.Settings` actually is the singleton instance of this class. .. class:: Connection This class represents the :data:`org.freedesktop.NetworkManager.Settings.Connection` interface. .. class:: ActiveConnection This class represents the :data:`org.freedesktop.NetworkManager.Connection.Active` interface. .. class:: AccessPoint This class represents the :data:`org.freedesktop.NetworkManager.AccessPoint` interface. .. class:: Device .. class:: Wired .. class:: Wireless .. class:: Modem .. class:: Bluetooth .. class:: OlpcMesh .. class:: Wimax .. class:: Infiniband .. class:: Bond .. class:: Bridge .. class:: Vlan .. class:: Adsl These classes represent D-Bus interfaces for various types of hardware. Note that methods such as :data:`NetworkManager.GetDevices()` will only return :class:`Device` instances. To get the hardware-specific class, you can call the :func:`Device.SpecificDevice` method. .. code-block:: py >>> [(dev.Interface, dev.SpecificDevice().__class__.__name__) ... for dev in NetworkManager.NetworkManager.GetDevices()] [('eth0', 'Wired'), ('wlan0', 'Wireless'), ('wwan0', 'Modem')] .. class:: IP4Config .. class:: IP6Config .. class:: DHCP4Config .. class:: DHCP6Config These classes represent the various IP configuration interfaces. .. class:: AgentManager .. class:: SecretAgent Classes that can be used to handle and store secrets. Note that these are not for querying NetworkManager's exisiting secret stores. For that the :func:`GetSecrets` method of the :class:`Connection` class can be used. .. class:: VPNConnection This class represents the :data:`org.freedesktop.NetworkManager.VPN.Connection` interface. .. class:: VPNPlugin A class that can be used to query VPN plugins. .. toctree:: :maxdepth: 2 The n-m utility --------------- n-m is a command-line tool to interact with NetworkManager. With it, you can inspect various configuration items and (de-)activate connections. Usage: [options] action [arguments] Actions: list - List all defined and active connections activate - Activate a connection deactivate - Deactivate a connection offline - Deactivate all connections enable - Enable specific connection types disable - Disable specific connection types info - Information about a connection dump - Dump a python hash of connection information, suitable for creating new connections python-networkmanager-0.9.10/docs/Makefile0000664000175000017500000001105211654621662021330 0ustar dennisdennis00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-networkmanager.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-networkmanager.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/python-networkmanager" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/python-networkmanager" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." make -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." python-networkmanager-0.9.10/examples/0000775000175000017500000000000012211043706020542 5ustar dennisdennis00000000000000python-networkmanager-0.9.10/examples/openvpn_over_ssh.py0000664000175000017500000000355412123652075024527 0ustar dennisdennis00000000000000""" I use a VPN that sits behind an SSH host, so I have to tunnel the VPN traffic over an SSH tunnel. I wanted to do that in one commadn, this prompted me to learn about the NetworkManager D-Bus API and now resulted in python-networkmanager. """ import dbus.mainloop.glib; dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) import NetworkManager import socket import subprocess import sys VPN_NAME = 'MyVpn' SSH_HOST = 'my.ssh.bastion.host.com' VPN_HOST = 'my.internal.vpn.host.com:1194' LOCALPORT = 1195 SSH = '/usr/bin/ssh' # Try connecting to LOCALPORT to see if the tunnel is alive sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(3) try: sock.connect(('localhost', LOCALPORT)) except socket.error: # Set up the SSH tunnel if it isn't print("Connecting to " + SSH_HOST) if subprocess.call([SSH, '-L%s:%s' % (LOCALPORT, VPN_HOST), '-f', '-n', '-N', SSH_HOST]) != 0: print("SSH to %s failed" % SSH_HOST) sys.exit(1) for conn in NetworkManager.Settings.ListConnections(): settings = conn.GetSettings() if settings['connection']['type'] == 'vpn' and settings['connection']['id'] == VPN_NAME: vpn = conn uuid = settings['connection']['uuid'] break else: print("VPN with name %s not found" % VPN_NAME) sys.exit(1) # Bail out of another vpn is active for conn in NetworkManager.NetworkManager.ActiveConnections: if conn.Vpn: vid = conn.Connection.GetSettings()['connection']['id'] print("The vpn %s is already active" % vid) sys.exit(1) # Activate VPN for dev in NetworkManager.NetworkManager.GetDevices(): if dev.State == NetworkManager.NM_DEVICE_STATE_ACTIVATED and dev.Managed: break else: print("No active, managed device found") sys.exit(1) print("Activating VPN") NetworkManager.NetworkManager.ActivateConnection(vpn, dev, "/") python-networkmanager-0.9.10/examples/info.py0000664000175000017500000000412711763717462022075 0ustar dennisdennis00000000000000""" Display information about everything network-related that network-manager can say something about. """ import NetworkManager c = NetworkManager.const print("%-30s %s" % ("Version:", NetworkManager.NetworkManager.Version)) print("%-30s %s" % ("Hostname:", NetworkManager.Settings.Hostname)) print("%-30s %s" % ("Can modify:", NetworkManager.Settings.CanModify)) print("%-30s %s" % ("Networking enabled:", NetworkManager.NetworkManager.NetworkingEnabled)) print("%-30s %s" % ("Wireless enabled:", NetworkManager.NetworkManager.WirelessEnabled)) print("%-30s %s" % ("Wireless hw enabled:", NetworkManager.NetworkManager.WirelessHardwareEnabled)) print("%-30s %s" % ("Wwan enabled:", NetworkManager.NetworkManager.WwanEnabled)) print("%-30s %s" % ("Wwan hw enabled:", NetworkManager.NetworkManager.WwanHardwareEnabled)) print("%-30s %s" % ("Wimax enabled:", NetworkManager.NetworkManager.WimaxEnabled)) print("%-30s %s" % ("Wimax hw enabled:", NetworkManager.NetworkManager.WimaxHardwareEnabled)) print("%-30s %s" % ("Overall state:", c('state', NetworkManager.NetworkManager.State))) print("") print("Permissions") for perm, val in sorted(NetworkManager.NetworkManager.GetPermissions().items()): print("%-30s %s" % (perm[31:] + ':', val)) print("") print("Available network devices") print("%-10s %-19s %-20s %s" % ("Name", "State", "Driver", "Managed?")) for dev in NetworkManager.NetworkManager.GetDevices(): print("%-10s %-19s %-20s %s" % (dev.Interface, c('device_state', dev.State), dev.Driver, dev.Managed)) print("") print("Available connections") print("%-30s %s" % ("Name", "Type")) for conn in NetworkManager.Settings.ListConnections(): settings = conn.GetSettings()['connection'] print("%-30s %s" % (settings['id'], settings['type'])) print("") print("Active connections") print("%-30s %-20s %-10s %s" % ("Name", "Type", "Default", "Devices")) for conn in NetworkManager.NetworkManager.ActiveConnections: settings = conn.Connection.GetSettings()['connection'] print("%-30s %-20s %-10s %s" % (settings['id'], settings['type'], conn.Default, ", ".join([x.Interface for x in conn.Devices]))) python-networkmanager-0.9.10/examples/listener.py0000664000175000017500000000234611763717462022770 0ustar dennisdennis00000000000000""" Listen to some available signals from NetworkManager """ import dbus.mainloop.glib; dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) from gi.repository import GObject import NetworkManager d_args = ('sender', 'destination', 'interface', 'member', 'path') d_args = dict([(x + '_keyword', 'd_' + x) for x in d_args]) def main(): NetworkManager.NetworkManager.connect_to_signal('CheckPermissions', display_sig, **d_args) NetworkManager.NetworkManager.connect_to_signal('StateChanged', display_sig, **d_args) NetworkManager.NetworkManager.connect_to_signal('PropertiesChanged', display_sig, **d_args) NetworkManager.NetworkManager.connect_to_signal('DeviceAdded', display_sig, **d_args) NetworkManager.NetworkManager.connect_to_signal('DeviceRemoved', display_sig, **d_args) print("Waiting for signals") print("-------------------") loop = GObject.MainLoop() loop.run() def display_sig(*args, **kwargs): print("Received signal: %s.%s" % (kwargs['d_interface'], kwargs['d_member'])) print("Sender: (%s)%s" % (kwargs['d_sender'], kwargs['d_path'])) print("Arguments: (%s)" % ", ".join([str(x) for x in args])) print("-------------------") if __name__ == '__main__': main() python-networkmanager-0.9.10/examples/activate_connection.py0000664000175000017500000000227112123652075025144 0ustar dennisdennis00000000000000""" Activate a connection by name """ import NetworkManager import sys # Find the connection name = sys.argv[1] connections = NetworkManager.Settings.ListConnections() connections = dict([(x.GetSettings()['connection']['id'], x) for x in connections]) conn = connections[name] # Find a suitable device ctype = conn.GetSettings()['connection']['type'] if ctype == 'vpn': for dev in NetworkManager.NetworkManager.GetDevices(): if dev.State == NetworkManager.NM_DEVICE_STATE_ACTIVATED and dev.Managed: break else: print("No active, managed device found") sys.exit(1) else: dtype = { '802-11-wireless': NetworkManager.NM_DEVICE_TYPE_WIFI, '802-3-ethernet': NetworkManager.NM_DEVICE_TYPE_ETHERNET, 'gsm': NetworkManager.NM_DEVICE_TYPE_MODEM, }.get(ctype,ctype) devices = NetworkManager.NetworkManager.GetDevices() for dev in devices: if dev.DeviceType == dtype and dev.State == NetworkManager.NM_DEVICE_STATE_DISCONNECTED: break else: print("No suitable and available %s device found" % ctype) sys.exit(1) # And connect NetworkManager.NetworkManager.ActivateConnection(conn, dev, "/") python-networkmanager-0.9.10/examples/connection_detail.py0000664000175000017500000000335112123652075024606 0ustar dennisdennis00000000000000""" Display detailed information about currently active connections. """ import NetworkManager c = NetworkManager.const for conn in NetworkManager.NetworkManager.ActiveConnections: settings = conn.Connection.GetSettings() for s in list(settings.keys()): if 'data' in settings[s]: settings[s + '-data'] = settings[s].pop('data') secrets = conn.Connection.GetSecrets() for key in secrets: settings[key].update(secrets[key]) devices = "" if conn.Devices: devices = " (on %s)" % ", ".join([x.Interface for x in conn.Devices]) print("Active connection: %s%s" % (settings['connection']['id'], devices)) size = max([max([len(y) for y in x.keys()]) for x in settings.values()]) format = " %%-%ds %%s" % (size + 5) for key, val in sorted(settings.items()): print(" %s" % key) for name, value in val.items(): print(format % (name, value)) for dev in conn.Devices: print("Device: %s" % dev.Interface) print(" Type %s" % c('device_type', dev.DeviceType)) # print(" IPv4 address %s" % socket.inet_ntoa(struct.pack('L', dev.Ip4Address))) devicedetail = dev.SpecificDevice() if not callable(devicedetail.HwAddress): print(" MAC address %s" % devicedetail.HwAddress) print(" IPv4 config") print(" Addresses") for addr in dev.Ip4Config.Addresses: print(" %s/%d -> %s" % tuple(addr)) print(" Routes") for route in dev.Ip4Config.Routes: print(" %s/%d -> %s (%d)" % tuple(route)) print(" Nameservers") for ns in dev.Ip4Config.Nameservers: print(" %s" % ns) python-networkmanager-0.9.10/examples/add_connection.py0000664000175000017500000000166712123652075024104 0ustar dennisdennis00000000000000""" Add a connection to NetworkManager. You do this by sending a dict to AddConnection. The dict below was generated with n-m dump on an existing connection and then anonymised """ import NetworkManager import uuid example_connection = { '802-11-wireless': {'mode': 'infrastructure', 'security': '802-11-wireless-security', 'ssid': 'n-m-example-connection'}, '802-11-wireless-security': {'auth-alg': 'open', 'key-mgmt': 'wpa-eap'}, '802-1x': {'eap': ['peap'], 'identity': 'eap-identity-goes-here', 'password': 'eap-password-goes-here', 'phase2-auth': 'mschapv2'}, 'connection': {'id': 'nm-example-connection', 'type': '802-11-wireless', 'uuid': str(uuid.uuid4())}, 'ipv4': {'method': 'auto'}, 'ipv6': {'method': 'auto'} } NetworkManager.Settings.AddConnection(example_connection) python-networkmanager-0.9.10/README0000664000175000017500000000156412123652075017621 0ustar dennisdennis00000000000000python-networkmanager Easy communication with NetworkManager ============================================================ python-networkmanager wraps NetworkManagers D-Bus interface so you can be less verbose when talking to NetworkManager from python. All interfaces have been wrapped in classes, properties are exposed as python properties and function calls are forwarded to the correct interface. See docs/index.rst for the documentation. An HTML version can be found on http://packages.python.org/python-networkmanager/ Requirements ============ Python 2.5 or newer (Python 3 is supported as well) and the python D-Bus bindings. Quick install instructions ========================== Stable version: $ sudo easy_install python-networkmanager Latest code: $ git clone http://github.com/seveas/python-networkmanager $ cd python-networkmanager $ sudo python setup.py install python-networkmanager-0.9.10/COPYING0000664000175000017500000000134312123652075017767 0ustar dennisdennis00000000000000python-networkmanager - Easy communication with NetworkManager Copyright (C) 2011 Dennis Kaarsemaker 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 3 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, see . python-networkmanager-0.9.10/n-m0000775000175000017500000001777112165603470017366 0ustar dennisdennis00000000000000#!/usr/bin/python # # Command-line tool to interact with NetworkManager. With this tool, you can # inspect various configuration items and (de-)activate connections. # # (C) 2011-2013 Dennis Kaarsemaker # License: GPL3+ from __future__ import print_function usage = """%prog [options] action [arguments] Actions: list - List all defined and active connections activate - Activate a connection deactivate - Deactivate a connection offline - Deactivate all connections enable - Enable specific connection types disable - Disable specific connection types info - Information about a connection""" import datetime from dbus.exceptions import DBusException import NetworkManager import optparse import socket import struct import sys PY3 = sys.version_info[0] >= 3 def main(): p = optparse.OptionParser(usage=usage) opts, args = p.parse_args() if not args: p.print_help() sys.exit(1) if args[0] == 'list': list_() elif args[0] == 'offline': offline() elif args[0] == 'visible': visible() elif len(args) < 2: p.print_help() sys.exit(1) elif args[0] == 'activate': activate(args[1:]) elif args[0] == 'deactivate': deactivate(args[1:]) elif args[0] == 'enable': enable(args[1:]) elif args[0] == 'disable': disable(args[1:]) elif args[0] == 'info': info(args[1:]) elif args[0] == 'dump': dump(args[1:]) else: p.print_help() sys.exit(1) def list_(): active = [x.Connection.GetSettings()['connection']['id'] for x in NetworkManager.NetworkManager.ActiveConnections] connections = [(x.GetSettings()['connection']['id'], x.GetSettings()['connection']['type']) for x in NetworkManager.Settings.ListConnections()] fmt = "%%s %%-%ds %%s" % max([len(x[0]) for x in connections]) for conn in sorted(connections): prefix = '* ' if conn[0] in active else ' ' print(fmt % (prefix, conn[0], conn[1])) def activate(names): connections = NetworkManager.Settings.ListConnections() connections = dict([(x.GetSettings()['connection']['id'], x) for x in connections]) if not NetworkManager.NetworkManager.NetworkingEnabled: NetworkManager.NetworkManager.Enable(True) for n in names: if n not in connections: print("No such connection: %s" % n, file=sys.stderr) sys.exit(1) print("Activating connection '%s'" % n) conn = connections[n] ctype = conn.GetSettings()['connection']['type'] if ctype == 'vpn': for dev in NetworkManager.NetworkManager.GetDevices(): if dev.State == NetworkManager.NM_DEVICE_STATE_ACTIVATED and dev.Managed: break else: print("No active, managed device found", file=sys.stderr) sys.exit(1) else: dtype = { '802-11-wireless': 'wlan', 'gsm': 'wwan', } if dtype in connection_types: enable(dtype) dtype = { '802-11-wireless': NetworkManager.NM_DEVICE_TYPE_WIFI, '802-3-ethernet': NetworkManager.NM_DEVICE_TYPE_ETHERNET, 'gsm': NetworkManager.NM_DEVICE_TYPE_MODEM, }.get(ctype,ctype) devices = NetworkManager.NetworkManager.GetDevices() for dev in devices: if dev.DeviceType == dtype and dev.State == NetworkManager.NM_DEVICE_STATE_DISCONNECTED: break else: print("No suitable and available %s device found" % ctype, file=sys.stderr) sys.exit(1) NetworkManager.NetworkManager.ActivateConnection(conn, dev, "/") def deactivate(names): active = NetworkManager.NetworkManager.ActiveConnections active = dict([(x.Connection.GetSettings()['connection']['id'], x) for x in active]) for n in names: if n not in active: print("No such connection: %s" % n, file=sys.stderr) sys.exit(1) print("Deactivating connection '%s'" % n) NetworkManager.NetworkManager.DeactivateConnection(active[n]) def offline(): try: NetworkManager.NetworkManager.Enable(False) except DBusException as e: if e.get_dbus_name() != 'org.freedesktop.NetworkManager.AlreadyEnabledOrDisabled': raise connection_types = ['wireless','wwan','wimax'] def enable(names): for n in names: if n not in connection_types: print("No such connection type: %s" % n, file=sys.stderr) sys.exit(1) setattr(NetworkManager.NetworkManager, n.title() + 'Enabled', True) def disable(names): for n in names: if n not in connection_types: print("No such connection type: %s" % n, file=sys.stderr) sys.exit(1) setattr(NetworkManager.NetworkManager, n.title() + 'Enabled', False) def info(names): connections = [x.GetSettings() for x in NetworkManager.Settings.ListConnections()] connections = dict([(x['connection']['id'], x) for x in connections]) for n in names: if not PY3: n = n.decode('utf-8') if n not in connections: print("No such connection: %s" % n, file=sys.stderr) return line = "Info about '%s'" % n print(line + "\n" + '=' * len(line)) conn = connections[n] print("Type:", conn['connection']['type']) print("Connect automatically:", ["No","Yes"][conn['connection'].get('autoconnect', True)]) if 'timestamp' in conn['connection']: print("Last connected on:", str(datetime.datetime.fromtimestamp(conn['connection']['timestamp']))) else: print("Never connected") print("IPv4 settings (%s)" % conn['ipv4']['method']) print(" Address(es):", ', '.join([x[0] for x in conn['ipv4']['addresses']]) or '(Automatic)') print(" DNS servers:", ', '.join(conn['ipv4']['dns']) or '(Automatic)') print(" Routes:", ", ".join(["%s/%d -> %s" % x[:3] for x in conn['ipv4']['routes']])) print(" Can be default route:", ["Yes","No"][conn['ipv4'].get('never-default', False)]) if conn['connection']['type'] == '802-3-ethernet': print("Physical link") print(" MAC address:", conn['802-3-ethernet'].get('mac-address', '(Automatic)')) elif conn['connection']['type'] == '802-11-wireless': print("Wireless link") print(" MAC address:", conn['802-11-wireless'].get('mac-address', '(Automatic)')) print(" SSID:", conn['802-11-wireless']['ssid']) if 'security' in conn['802-11-wireless']: print(" Wireless security:", conn[conn['802-11-wireless']['security']]['key-mgmt']) elif conn['connection']['type'] == 'vpn': print("VPN") print(" Type:", conn['vpn']['service-type'].rsplit('.',1)[-1]) print(" Remote:", conn['vpn']['data']['remote']) def dump(names): from pprint import pprint connections = {} for conn in NetworkManager.Settings.ListConnections(): settings = conn.GetSettings() secrets = conn.GetSecrets() for key in secrets: settings[key].update(secrets[key]) connections[settings['connection']['id']] = settings for n in names: if n not in connections: print("No such connection: %s" % n, file=sys.stderr) pprint(connections[n]) def visible(): for device in NetworkManager.NetworkManager.GetDevices(): if device.DeviceType != NetworkManager.NM_DEVICE_TYPE_WIFI: continue print("Visible on %s" % device.Udi[device.Udi.rfind('/')+1:]) device = device.SpecificDevice() active = device.ActiveAccessPoint aps = device.GetAccessPoints() for ap in aps: prefix = '* ' if ap.object_path == active.object_path else ' ' print("%s %s" % (prefix, ap.Ssid)) if __name__ == '__main__': main() python-networkmanager-0.9.10/NetworkManager.py0000664000175000017500000004763312211043534022236 0ustar dennisdennis00000000000000# NetworkManager - a library to make interacting with the NetworkManager daemon # easier. # # (C)2011-2013 Dennis Kaarsemaker # License: GPL3+ import dbus import os import socket import struct import sys PY3 = sys.version_info >= (3,0) if PY3: basestring = str unicode = str elif not hasattr(__builtins__, 'bytes'): bytes = lambda x, y=None: chr(x[0]) if x else x try: debuglevel = int(os.environ['NM_DEBUG']) def debug(msg, data): sys.stderr.write(msg + "\n") sys.stderr.write(repr(data)+"\n") except: debug = lambda *args: None class NMDbusInterface(object): bus = dbus.SystemBus() dbus_service = 'org.freedesktop.NetworkManager' object_path = None def __init__(self, object_path=None): if isinstance(object_path, NMDbusInterface): object_path = object_path.object_path self.object_path = self.object_path or object_path self.proxy = self.bus.get_object(self.dbus_service, self.object_path) self.interface = dbus.Interface(self.proxy, self.interface_name) properties = [] try: properties = self.proxy.GetAll(self.interface_name, dbus_interface='org.freedesktop.DBus.Properties') except dbus.exceptions.DBusException as e: if e.get_dbus_name() != 'org.freedesktop.DBus.Error.UnknownMethod': raise for p in properties: p = str(p) if not hasattr(self.__class__, p): setattr(self.__class__, p, self._make_property(p)) def _make_property(self, name): def get(self): data = self.proxy.Get(self.interface_name, name, dbus_interface='org.freedesktop.DBus.Properties') debug("Received property %s.%s" % (self.interface_name, name), data) return self.postprocess(name, self.unwrap(data)) def set(self, value): data = self.wrap(self.preprocess(name, data)) debug("Setting property %s.%s" % (self.interface_name, name), value) return self.proxy.Set(self.interface_name, name, value, dbus_interface='org.freedesktop.DBus.Properties') return property(get, set) def unwrap(self, val): if isinstance(val, dbus.ByteArray): return "".join([str(x) for x in val]) if isinstance(val, (dbus.Array, list, tuple)): return [self.unwrap(x) for x in val] if isinstance(val, (dbus.Dictionary, dict)): return dict([(self.unwrap(x), self.unwrap(y)) for x,y in val.items()]) if isinstance(val, dbus.ObjectPath): if val.startswith('/org/freedesktop/NetworkManager/'): classname = val.split('/')[4] classname = { 'Settings': 'Connection', 'Devices': 'Device', }.get(classname, classname) return globals()[classname](val) if isinstance(val, (dbus.Signature, dbus.String)): return unicode(val) if isinstance(val, dbus.Boolean): return bool(val) if isinstance(val, (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64)): return int(val) if isinstance(val, dbus.Byte): return bytes([int(val)]) return val def wrap(self, val): if isinstance(val, NMDbusInterface): return val.object_path if hasattr(val, 'mro'): for klass in val.mro(): if klass.__module__ == '_dbus_bindings': return val if hasattr(val, '__iter__') and not isinstance(val, basestring): if hasattr(val, 'items'): return dict([(x, self.wrap(y)) for x, y in val.items()]) else: return [self.wrap(x) for x in val] return val def __getattr__(self, name): try: return super(NMDbusInterface, self).__getattribute__(name) except AttributeError: return self.make_proxy_call(name) def make_proxy_call(self, name): def proxy_call(*args, **kwargs): func = getattr(self.interface, name) args, kwargs = self.preprocess(name, args, kwargs) args = self.wrap(args) kwargs = self.wrap(kwargs) debug("Calling function %s.%s" % (self.interface_name, name), (args, kwargs)) ret = func(*args, **kwargs) debug("Received return value for %s.%s" % (self.interface_name, name), ret) return self.postprocess(name, self.unwrap(ret)) return proxy_call def connect_to_signal(self, signal, handler, *args, **kwargs): def helper(*args, **kwargs): args = [self.unwrap(x) for x in args] handler(*args, **kwargs) args = self.wrap(args) kwargs = self.wrap(kwargs) return self.proxy.connect_to_signal(signal, helper, *args, **kwargs) def postprocess(self, name, val): return val def preprocess(self, name, args, kwargs): return args, kwargs class NetworkManager(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager' object_path = '/org/freedesktop/NetworkManager' def preprocess(self, name, args, kwargs): if name in ('AddConnection', 'Update', 'AddAndActivateConnection'): settings = args[0] for key in settings: if 'mac-address' in settings[key]: settings[key]['mac-address'] = fixups.mac_to_dbus(settings[key]['mac-address']) if 'bssid' in settings[key]: settings[key]['bssid'] = fixups.mac_to_dbus(settings[key]['mac-address']) if 'ssid' in settings.get('802-11-wireless', {}): settings['802-11-wireless']['ssid'] = fixups.ssid_to_dbus(settings['802-11-wireless']['ssid']) if 'ipv4' in settings: if 'addresses' in settings['ipv4']: settings['ipv4']['addresses'] = [fixups.addrconf_to_dbus(addr) for addr in settings['ipv4']['addresses']] if 'routes' in settings['ipv4']: settings['ipv4']['routes'] = [fixups.route_to_dbus(route) for route in settings['ipv4']['routes']] if 'dns' in settings['ipv4']: settings['ipv4']['dns'] = [fixups.addr_to_dbus(addr) for addr in settings['ipv4']['dns']] return args, kwargs NetworkManager = NetworkManager() class Settings(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Settings' object_path = '/org/freedesktop/NetworkManager/Settings' preprocess = NetworkManager.preprocess Settings = Settings() class Connection(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Settings.Connection' has_secrets = ['802-1x', '802-11-wireless-security', 'cdma', 'gsm', 'pppoe', 'vpn'] def GetSecrets(self, name=None): if name == None: settings = self.GetSettings() for key in self.has_secrets: if key in settings: name = key break else: return {} return self.make_proxy_call('GetSecrets')(name) def postprocess(self, name, val): if name == 'GetSettings': if 'ssid' in val.get('802-11-wireless', {}): val['802-11-wireless']['ssid'] = fixups.ssid_to_python(val['802-11-wireless']['ssid']) for key in val: val_ = val[key] if 'mac-address' in val_: val_['mac-address'] = fixups.mac_to_python(val_['mac-address']) if 'bssid' in val_: val_['bssid'] = fixups.mac_to_python(val_['bssid']) if 'ipv4' in val: val['ipv4']['addresses'] = [fixups.addrconf_to_python(addr) for addr in val['ipv4']['addresses']] val['ipv4']['routes'] = [fixups.route_to_python(route) for route in val['ipv4']['routes']] val['ipv4']['dns'] = [fixups.addr_to_python(addr) for addr in val['ipv4']['dns']] return val preprocess = NetworkManager.preprocess class ActiveConnection(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Connection.Active' class Device(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device' def SpecificDevice(self): return { NM_DEVICE_TYPE_ETHERNET: Wired, NM_DEVICE_TYPE_WIFI: Wireless, NM_DEVICE_TYPE_MODEM: Modem, NM_DEVICE_TYPE_BT: Bluetooth, NM_DEVICE_TYPE_OLPC_MESH: OlpcMesh, NM_DEVICE_TYPE_WIMAX: Wimax, NM_DEVICE_TYPE_INFINIBAND: Infiniband, NM_DEVICE_TYPE_BOND: Bond, NM_DEVICE_TYPE_VLAN: Vlan, NM_DEVICE_TYPE_ADSL: Adsl, }[self.DeviceType](self.object_path) def postprocess(self, name, val): if name == 'Ip4Address': return fixups.addr_to_python(val) return val class AccessPoint(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.AccessPoint' def postprocess(self, name, val): if name == 'Ssid': return fixups.ssid_to_python(val) return val class Wired(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Wired' class Wireless(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Wireless' class Modem(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Modem' class Bluetooth(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Bluetooth' class OlpcMesh(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.OlpcMesh' class Wimax(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Wimax' class Infiniband(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Infiniband' class Bond(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Bond' class Bridge(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Bridge' class Vlan(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.Vlan' class Adsl(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Device.adsl' class NSP(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.Wimax.NSP' class IP4Config(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.IP4Config' def postprocess(self, name, val): if name == 'Addresses': return [fixups.addrconf_to_python(addr) for addr in val] if name == 'Routes': return [fixups.route_to_python(route) for route in val] if name in ('Nameservers', 'WinsServers'): return [fixups.addr_to_python(addr) for addr in val] return val class IP6Config(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.IP6Config' class DHCP4Config(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.DHCP4Config' class DHCP6Config(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.DHCP6Config' class AgentManager(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.AgentManager' class SecretAgent(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.SecretAgent' class VPNConnection(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.VPN.Connection' def preprocess(self, name, args, kwargs): conf = args[0] conf['addresses'] = [fixups.addrconf_to_python(addr) for addr in conf['addresses']] conf['routes'] = [fixups.route_to_python(route) for route in conf['routes']] conf['dns'] = [fixups.addr_to_python(addr) for addr in conf['dns']] return args, kwargs class VPNPlugin(NMDbusInterface): interface_name = 'org.freedesktop.NetworkManager.VPN.Plugin' def const(prefix, val): prefix = 'NM_' + prefix.upper() + '_' for key, vval in globals().items(): if 'REASON' in key and 'REASON' not in prefix: continue if key.startswith(prefix) and val == vval: return key.replace(prefix,'').lower() raise ValueError("No constant found for %s* with value %d", (prefix, val)) # Several fixer methods to make the data easier to handle in python # - SSID sent/returned as bytes (only encoding tried is utf-8) # - IP, Mac address and route metric encoding/decoding class fixups(object): @staticmethod def ssid_to_python(ssid): return bytes("",'ascii').join(ssid).decode('utf-8') @staticmethod def ssid_to_dbus(ssid): if isinstance(ssid, unicode): ssid = ssid.encode('utf-8') return [dbus.Byte(x) for x in ssid] @staticmethod def mac_to_python(mac): return "%02X:%02X:%02X:%02X:%02X:%02X" % tuple([ord(x) for x in mac]) @staticmethod def mac_to_dbus(mac): return [dbus.Byte(int(x, 16)) for x in mac.split(':')] @staticmethod def addrconf_to_python(addrconf): addr, netmask, gateway = addrconf return [ fixups.addr_to_python(addr), netmask, fixups.addr_to_python(gateway) ] @staticmethod def addrconf_to_dbus(addrconf): addr, netmask, gateway = addrconf return [ fixups.addr_to_dbus(addr), fixups.mask_to_dbus(netmask), fixups.addr_to_dbus(gateway) ] @staticmethod def addr_to_python(addr): return socket.inet_ntoa(struct.pack('I', addr)) @staticmethod def addr_to_dbus(addr): return dbus.UInt32(struct.unpack('I', socket.inet_aton(addr))[0]) @staticmethod def mask_to_dbus(mask): return dbus.UInt32(mask) @staticmethod def route_to_python(route): addr, netmask, gateway, metric = route return [ fixups.addr_to_python(addr), netmask, fixups.addr_to_python(gateway), socket.ntohl(metric) ] @staticmethod def route_to_dbus(route): addr, netmask, gateway, metric = route return [ fixups.addr_to_dbus(addr), fixups.mask_to_dbus(netmask), fixups.addr_to_dbus(gateway), socket.htonl(metric) ] # Constants below are generated with makeconstants.py. Do not edit manually. NM_STATE_UNKNOWN = 0 NM_STATE_ASLEEP = 10 NM_STATE_DISCONNECTED = 20 NM_STATE_DISCONNECTING = 30 NM_STATE_CONNECTING = 40 NM_STATE_CONNECTED_LOCAL = 50 NM_STATE_CONNECTED_SITE = 60 NM_STATE_CONNECTED_GLOBAL = 70 NM_DEVICE_TYPE_UNKNOWN = 0 NM_DEVICE_TYPE_ETHERNET = 1 NM_DEVICE_TYPE_WIFI = 2 NM_DEVICE_TYPE_UNUSED1 = 3 NM_DEVICE_TYPE_UNUSED2 = 4 NM_DEVICE_TYPE_BT = 5 NM_DEVICE_TYPE_OLPC_MESH = 6 NM_DEVICE_TYPE_WIMAX = 7 NM_DEVICE_TYPE_MODEM = 8 NM_DEVICE_TYPE_INFINIBAND = 9 NM_DEVICE_TYPE_BOND = 10 NM_DEVICE_TYPE_VLAN = 11 NM_DEVICE_TYPE_ADSL = 12 NM_DEVICE_CAP_NONE = 0 NM_DEVICE_CAP_NM_SUPPORTED = 1 NM_DEVICE_CAP_CARRIER_DETECT = 2 NM_WIFI_DEVICE_CAP_NONE = 0 NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 1 NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 2 NM_WIFI_DEVICE_CAP_CIPHER_TKIP = 4 NM_WIFI_DEVICE_CAP_CIPHER_CCMP = 8 NM_WIFI_DEVICE_CAP_WPA = 16 NM_WIFI_DEVICE_CAP_RSN = 32 NM_WIFI_DEVICE_CAP_AP = 64 NM_WIFI_DEVICE_CAP_IBSS_RSN = 128 NM_802_11_AP_FLAGS_NONE = 0 NM_802_11_AP_FLAGS_PRIVACY = 1 NM_802_11_AP_SEC_NONE = 0 NM_802_11_AP_SEC_PAIR_WEP40 = 1 NM_802_11_AP_SEC_PAIR_WEP104 = 2 NM_802_11_AP_SEC_PAIR_TKIP = 4 NM_802_11_AP_SEC_PAIR_CCMP = 8 NM_802_11_AP_SEC_GROUP_WEP40 = 16 NM_802_11_AP_SEC_GROUP_WEP104 = 32 NM_802_11_AP_SEC_GROUP_TKIP = 64 NM_802_11_AP_SEC_GROUP_CCMP = 128 NM_802_11_AP_SEC_KEY_MGMT_PSK = 256 NM_802_11_AP_SEC_KEY_MGMT_802_1X = 512 NM_802_11_MODE_UNKNOWN = 0 NM_802_11_MODE_ADHOC = 1 NM_802_11_MODE_INFRA = 2 NM_BT_CAPABILITY_NONE = 0 NM_BT_CAPABILITY_DUN = 1 NM_BT_CAPABILITY_NAP = 2 NM_DEVICE_MODEM_CAPABILITY_NONE = 0 NM_DEVICE_MODEM_CAPABILITY_POTS = 1 NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 2 NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 4 NM_DEVICE_MODEM_CAPABILITY_LTE = 8 NM_DEVICE_STATE_UNKNOWN = 0 NM_DEVICE_STATE_UNMANAGED = 10 NM_DEVICE_STATE_UNAVAILABLE = 20 NM_DEVICE_STATE_DISCONNECTED = 30 NM_DEVICE_STATE_PREPARE = 40 NM_DEVICE_STATE_CONFIG = 50 NM_DEVICE_STATE_NEED_AUTH = 60 NM_DEVICE_STATE_IP_CONFIG = 70 NM_DEVICE_STATE_IP_CHECK = 80 NM_DEVICE_STATE_SECONDARIES = 90 NM_DEVICE_STATE_ACTIVATED = 100 NM_DEVICE_STATE_DEACTIVATING = 110 NM_DEVICE_STATE_FAILED = 120 NM_DEVICE_STATE_REASON_NONE = 0 NM_DEVICE_STATE_REASON_UNKNOWN = 1 NM_DEVICE_STATE_REASON_NOW_MANAGED = 2 NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3 NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4 NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5 NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6 NM_DEVICE_STATE_REASON_NO_SECRETS = 7 NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8 NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9 NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10 NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11 NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12 NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13 NM_DEVICE_STATE_REASON_PPP_FAILED = 14 NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15 NM_DEVICE_STATE_REASON_DHCP_ERROR = 16 NM_DEVICE_STATE_REASON_DHCP_FAILED = 17 NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18 NM_DEVICE_STATE_REASON_SHARED_FAILED = 19 NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20 NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21 NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22 NM_DEVICE_STATE_REASON_MODEM_BUSY = 23 NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24 NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25 NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26 NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27 NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28 NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29 NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30 NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31 NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32 NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33 NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34 NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35 NM_DEVICE_STATE_REASON_REMOVED = 36 NM_DEVICE_STATE_REASON_SLEEPING = 37 NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38 NM_DEVICE_STATE_REASON_USER_REQUESTED = 39 NM_DEVICE_STATE_REASON_CARRIER = 40 NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41 NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42 NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43 NM_DEVICE_STATE_REASON_BT_FAILED = 44 NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45 NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46 NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47 NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48 NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49 NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50 NM_DEVICE_STATE_REASON_BR2684_FAILED = 51 NM_DEVICE_STATE_REASON_LAST = 65535 NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0 NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1 NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2 NM_ACTIVE_CONNECTION_STATE_DEACTIVATING = 3 NM_VPN_SERVICE_STATE_UNKNOWN = 0 NM_VPN_SERVICE_STATE_INIT = 1 NM_VPN_SERVICE_STATE_SHUTDOWN = 2 NM_VPN_SERVICE_STATE_STARTING = 3 NM_VPN_SERVICE_STATE_STARTED = 4 NM_VPN_SERVICE_STATE_STOPPING = 5 NM_VPN_SERVICE_STATE_STOPPED = 6 NM_VPN_CONNECTION_STATE_UNKNOWN = 0 NM_VPN_CONNECTION_STATE_PREPARE = 1 NM_VPN_CONNECTION_STATE_NEED_AUTH = 2 NM_VPN_CONNECTION_STATE_CONNECT = 3 NM_VPN_CONNECTION_STATE_IP_CONFIG_GET = 4 NM_VPN_CONNECTION_STATE_ACTIVATED = 5 NM_VPN_CONNECTION_STATE_FAILED = 6 NM_VPN_CONNECTION_STATE_DISCONNECTED = 7 NM_VPN_CONNECTION_STATE_REASON_UNKNOWN = 0 NM_VPN_CONNECTION_STATE_REASON_NONE = 1 NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED = 2 NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED = 3 NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED = 4 NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID = 5 NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT = 6 NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT = 7 NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED = 8 NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS = 9 NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED = 10 NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED = 11 NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED = 0 NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED = 1 NM_VPN_PLUGIN_FAILURE_BAD_IP_CONFIG = 2 python-networkmanager-0.9.10/setup.py0000775000175000017500000000131712211043615020442 0ustar dennisdennis00000000000000#!/usr/bin/python from distutils.core import setup setup(name = "python-networkmanager", version = "0.9.10", author = "Dennis Kaarsemaker", author_email = "dennis@kaarsemaker.net", url = "http://github.com/seveas/python-networkmanager", description = "Easy communication with NetworkManager", py_modules = ["NetworkManager"], scripts = ["n-m"], classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', 'Topic :: System :: Networking', ] )