Permalink
Browse files

Bug 852296 - Add documentation for moznetwork;r=mcote

  • Loading branch information...
1 parent a930b26 commit 98003d3a30965a00046c537026b6c80abe256f27 @wlach wlach committed Mar 18, 2013
Showing with 49 additions and 15 deletions.
  1. +12 −0 docs/gettinginfo.rst
  2. +1 −1 docs/index.rst
  3. +3 −10 docs/mozinfo.rst
  4. +9 −0 docs/moznetwork.rst
  5. +19 −0 moznetwork/moznetwork/__init__.py
  6. +5 −4 moznetwork/moznetwork/moznetwork.py
View
@@ -0,0 +1,12 @@
+Getting information on the system under test
+============================================
+
+It's often necessary to get some information about the system we're
+testing, for example to turn on or off some platform specific
+behaviour.
+
+.. toctree::
+ :maxdepth: 2
+
+ mozinfo
+ moznetwork
View
@@ -42,7 +42,7 @@ want to do then dive in!
:maxdepth: 2
manifestdestiny
- mozinfo
+ gettinginfo
setuprunning
mozhttpd
loggingreporting
View
@@ -1,12 +1,5 @@
-Getting information on the system under test
-============================================
-
-It's often necessary to get some information about the system we're
-testing, for example to turn on or off some platform specific
-behaviour.
-
:mod:`mozinfo` --- Get system information
------------------------------------------
+=========================================
Throughout `mozmill <https://developer.mozilla.org/en/Mozmill>`_
and other Mozilla python code, checking the underlying
@@ -26,7 +19,7 @@ service pack in use is available on the windows platform.
API Usage
-`````````
+---------
mozinfo is a python package. Downloading the software and running
``python setup.py develop`` will allow you to do ``import mozinfo``
@@ -56,7 +49,7 @@ contain these values. mozinfo also exports:
Command Line Usage
-``````````````````
+------------------
mozinfo comes with a command line program, ``mozinfo`` which may be used to
diagnose one's current system.
View
@@ -0,0 +1,9 @@
+:mod:`moznetwork` --- Get network information
+=============================================
+
+.. automodule:: moznetwork
+
+ .. automethod:: moznetwork.get_ip
+
+ .. autoclass:: moznetwork.NetworkError
+
@@ -2,4 +2,23 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
+"""
+moznetwork is a very simple module designed for one task: getting the
+network address of the current machine.
+
+Example usage:
+
+::
+
+ import moznetwork
+
+ try:
+ ip = moznetwork.get_ip()
+ print "The external IP of your machine is '%s'" % ip
+ except moznetwork.NetworkError:
+ print "Unable to determine IP address of machine"
+ raise
+
+"""
+
from moznetwork import *
@@ -9,9 +9,8 @@
if os.name != 'nt':
import fcntl
-
class NetworkError(Exception):
- """Unable to obtain interface or IP"""
+ """Exception thrown when unable to obtain interface or IP."""
def _get_interface_list():
@@ -40,8 +39,10 @@ def _get_interface_list():
def get_ip():
- """Provides an available network interface address. A
- NetworkError exception is raised in case of failure."""
+ """Provides an available network interface address, for example
+ "192.168.1.3".
+
+ A `NetworkError` exception is raised in case of failure."""
try:
try:
ip = socket.gethostbyname(socket.gethostname())

0 comments on commit 98003d3

Please sign in to comment.