Tests for irnetbox.py and `stbt run --control=irnetbox`

These aren't intended to test that the protocol is correct, because I
implemented both ends (`irnetbox.py` and `fake-irnetbox`). I know that
the protocol is correct because I've tested irnetbox.py with a real
irNetBox device. However these tests give us some confidence that the
"glue" code around the sending of signals is correct.

`tests/fake-irnetbox` listens on an available port (and prints
"PORT=xxxx" to standard output), and just acks every message it
receives.

`irnetbox.IRNetBox.__init__` and `stbt run --control=irnetbox:...` now
accept an optional `port` parameter, when using the fake-irnetbox's port
-- a real irNetBox always uses port 10001. Since this is only for use in
the unit tests, it isn't documented in `README.rst`.

Note that `tests/run-tests.sh` now sets `PYTHONUNBUFFERED=x` so that
`fake-irnetbox`'s output goes to `fake-irnetbox.log` immediately;
otherwise the output is fully buffered and the test
`test_irnetbox_commands` fails with "error: fake-irnetbox failed to
start". See
http://docs.python.org/2/using/cmdline.html#envvar-PYTHONUNBUFFERED
tests/run-tests.sh: Set PYTHONPATH for irnetbox tests

Commit 9a4d2086 added a test that does `import irnetbox` but
`irnetbox.py` isn't on the PYTHONPATH. (When `stbt-run` imports
`irnetbox` it always worked because the current file's directory is
searched before PYTHONPATH, and `stbt-run` is in the same directory as
`irnetbox.py`).
runner/templates/testrun.html: Wrap failure reason to multiple lines

`white-space: pre` CSS property prevents the browser from wrapping the
text to multiple lines if it is too long; as a result, in many cases part
of the failure reason gets out of screen, even when the browser is expanded
to full screen.
extra/runner/report.py: Include "report.py" in error messages

There is also a shell script called `report` (which calls `report.py`)
so this change clarifies where the error message is coming from.
extra/runner/report: Don't resolve symlinks when determining results directory

The directory structure of a "test results" directory (where you ran
`extra/runner/run` from) looks like this:

    results/
    results/2013-08-10_09.54.29/
    results/2013-08-10_09.56.06/
    results/index.html

However, a user can manually create such a structure using symlinks
instead, when they want to create a report (using `extra/runner/report`)
that contains results from several different "test results" directories:

    summary/
    summary/2013-08-10_09.54.29-run1 -> ../results1/2013-08-10_09.54.29
    summary/2013-08-10_09.56.06-run1 -> ../results1/2013-08-10_09.56.06
    etc.

In that case, running `report summary/2013*` would create the summary
report in `results1/index.html` instead of `summary/index.html`. This
commit fixes that; there is no need to resolve symlinks when determining
the "test results" directory.

This uses python's `abspath` (which doesn't resolve symlinks) instead of
python's `realpath`. Since we *do* need to resolve symlinks elsewhere in
the `report` script†, we need both functions. The `run` script only uses
python's `realpath`, but I've renamed `run`'s shell function to
`realpath` for consistency with the python function name and for
consistency with `report`.

† To find the directory containing the `report.py` script (which is the
same directory that contains this `report` shell script). Some people
symlink `report` into a directory on their PATH (such as `~/bin`)
instead of adding the directory containing `report` to their PATH.
extra/runner/run: Don't run more tests if v4l2 capture device not found

This happens, for example, when the cleaners bump the power button on my
Hauppauge HDPVR that's running tests overnight.

Checking for "/dev/v" will match "/dev/video0" as well as
"/dev/v4l/by-id/..." (I use the latter in my source pipeline if the PC
has multiple devices connected, because the "by-id" path doesn't change
across PC reboots).
stbt.Display.teardown: Avoid additional exception after NoVideo timeout

If the NoVideo timeout happens after `restart_source` stopped the source
pipeline but before `start_source` started it again (there's a 5 second
gap), then the "NoVideo" exception would be followed by a second
exception message:

      File "/usr/libexec/stbt/stbt.py", line 920, in teardown
        self.source_pipeline.set_state(gst.STATE_NULL)
    AttributeError: 'NoneType' object has no attribute 'set_state'
Add a standalone irnetproxy.py script for the RedRat irNetBox III

The irNetBox only allows one network connection at a time.  This means
the 16 ir ports it has cannot be easily controlled by multiple clients
simultaneously.

This script allows many clients to connect to the device, and use
the ports concurrently.  **Note**, this only makes sense for the
Asynchronous IO Output Commands, other commands will be run
synchronously as before.

http://www.redrat.co.uk/products/IRNetBox_Comms-V3.X.pdf

Usage
-----

```
$ irnetproxy -r <irNetBox address>
```

OR

```
$ irnetproxy --irnetbox-addresss <irNetBox address> \
             --irnetbox-port 10001\
             --listen-port 10001\
             --listen-address 127.0.0.1\
             -vv

> Listening for connections on 127.0.0.1:10001
```

Existing irNetBox network clients should then connect to the proxy
server, rather than the irNetBox.  Everything else should behave the
same.

Features
--------

 - Session multiplexing: irnetproxy dynamically maps Asyncronous
   Sequence IDs on the fly, meaning that multiple clients can use the
   same Sequence ID concurrently, and the irnet box will continue to
   work.  Both the command acknowledgement, and the subsequent Async
   complete message are always routed to the correct client.

 - On/Off management: irnetproxy will silently accept the on and off
   messages (5 and 6).  A standard ACK response is returned to the
   client, but the command is never sent to the device. This allows
   multiple scripts to try to turn off the device while other devices
   use it.  irnetproxy issues the ON command when it connects, and
   issues an OFF command when it is stopped.
Add irnetproxy tests into the existing test runners

 * make check-pylint now runs on irnetproxy and irnetproxy_test
 * make check-nosetests includes the irnetproxy_test module
 * New python dependency 'mock' added to the .tests.yml file

Note, mock is pip installed because the version in the ubuntu
deb repositories is too old (doesn't support return_value= argument)
tests/fake-irnetbox: Log OUTPUT_IR_ASYNC sequence number

This helped me debug an endianness issue fixed in the next commit.
test_irnetbox_proxy: Isolated component test for irnetproxy.py

Using irnetproxy.py in between 2 `stbt run` clients and a fake irnetbox,
the test checks that each client gets the right responses.

Note that tests/fake-irnetbox now returns the sequence number in the
OUTPUT_IR_ASYNC ACK message in little-endian format. This is the
opposite of what the spec† says. This matches the implementation in
irnetproxy.py, which has been tested against 2 separate irNetBox-III
devices.

† http://www.redrat.co.uk/products/IRNetBox_Comms-V3.X.pdf
irnetproxy_test.py: Remove tests that require `mock` library

Because the library has to be pip-installed (see 10909cc9) which is yet
another dependency for people to install, and all our other dependencies
can be installed with the system package manager (yum, apt-get, etc).

Instead, I added some component tests in the previous commit.
Makefile: Cleanup: Rearrange order of files in `check-pylint` recipe

This keeps the `irnet*` files together, and the `stbt-*` files together,
and the `extra/` files together.
irnetbox.py: Cleanup documentation formatting

I'm going to add another paragraph to the `IRNetBox` class's
documentation in a future commit, so this will make it clearer
where one class's documentation ends and the next begins.

The indentation is reStructuredText's format for definition lists.
irnetbox.py docstring: Mention the irNetBox proxy
irnetproxy.py: Cleanup help message

The output of `./irnetproxy.py --help` used to be:

    usage: irnetproxy.py [-h] [-i LISTEN_ADDRESS] [-p LISTEN_PORT] -r
                         IRNET_ADDRESS [--irnetbox-port IRNET_PORT] [-v]

    A network proxy for RedRat irNetBox MK-III infra-red blaster modules.
    Based on the protocol document:
    http://www.redrat.co.uk/products/IRNetBox_Comms-V3.X.pdf This script
    allows many clients to connect to the device, and use the ports
    concurrently. **Note**, this only makes sense for the Asynchronous IO
    Output Commands, other commands will be run synchronously. Usage -----
    ``` $ irnetproxy -r <irNetBox address> ``` OR ``` $ irnetproxy
    [...]
irnetproxy.py: Cleanup: Remove unnecessary argparse `dest` arguments

http://docs.python.org/2.7/library/argparse.html#dest says:

> ArgumentParser generates the value of dest by taking the first long
> option string and stripping away the initial `--` string. Any internal
> `-` characters will be converted to `_` characters.
irnetproxy.py: Change "--verbosity" command-line argument to "--verbose"

And document the effect of specifying it twice.

The new name is consistent with other command-line utilities.
"--verbosity" should only be used for a flag that takes an argument,
like "--verbosity=2". For example see "nosetests --help".
irnetproxy.py: Mandatory arguments are positional, not flags

This follows the pattern of common tools like telnet, netcat, ssh:

    telnet host [port]
    nc hostname port
    ssh [-p port] [user@]hostname

I renamed "irnetbox-address" to "irnetbox_address" ("-" to "_") for
consistency with "LISTEN_ADDRESS" and "LISTEN_PORT" in argparse's
"--help" output:

    usage: irnetproxy.py [-h] [-v] [-l LISTEN_ADDRESS] [-p LISTEN_PORT]
                         irnetbox_address [irnetbox_port]
irnetproxy.py: "--listen-address" is "-l", not "-i"

Similarity with common command-line tools:

netcat uses "-l" to mean "listen" (though netcat's "-l" doesn't take an
argument; there's a separate, non-optional, positional "hostname"
argument).

telnet uses "-s" to specify a source address, but that is something
different that an address that a server binds to.

varnish, an http proxy, uses "-a address[:port]". I assume that "a"
stands for "address"; that's fine for varnish which only needs to
specify one address, but our irnetproxy needs to specify two addresses,
the address to listen on and the address of the real irNetBox. So I've
chosen "-l" as it's more explicitly the *listen* address.