stbt.py: Fix race condition: TypeError on NoVideo

During a NoVideo source pipeline reset `Display.source_pipeline` is
`None`.  If simultaneously `get_sample` times out stbt will try to dump
the source pipeline graph.  This causes `TypeError` to be raised:

      File ".../stbt/stbt.py", line 1493, in get_sample
        self.source_pipeline, Gst.DebugGraphDetails.ALL, "NoVideo")
    TypeError: Argument 0 does not allow None as a value

Thanks to Lewis Haley for reporting this bug and correctly diagnosing the
cause.

Fixes drothlis/#197
stbt._find_tessdata_dir: Honour TESSDATA_PREFIX

This allows me to use a locally-built (not installed) version of
tesseract for testing.
Merge pull request #200 from drothlis/tessdata-prefix

stbt._find_tessdata_dir: Honour TESSDATA_PREFIX
make check: nosetest more files (all "*.py" files)

37da66f8 tried to make `nosetests` check every python file, but filters
out files with "-" in the name because of the mistaken belief that
`nosetests` can't handle files with "-". In fact, `nosetests` can't
handle files that don't end in ".py"[1], and it was a coincidence that
all our python files that don't end in ".py" also have a "-" in the
filename.

37da66f8 filtered out some files that *do* end in ".py", such as
`stbt-batch.d/report.py` and `tests/validate-ocr.py`.

I had to pass an explicit `--match` pattern to `nosetests` so that it
wouldn't think that `report.testrun` in `stbt-batch.d/report.py` is a
unit test. Similarly, I had to rename `test` in `validate-ocr.py`
because it isn't a unit test.

[1] https://github.com/nose-devs/nose/issues/49
Merge pull request #202 from drothlis/nosetest-dot-py

make check: nosetest more files (all "*.py" files)
stbt._X11Remote.press: Log keypress

Just like all the other remote-control implementations. This makes
debugging test failures much easier.

Arguably the logging should be done by `stbt.press`, but for example the
`_SamsungTCPRemote.press` implementation logs "Pressed" first and then
logs the reply; and `NullRemote.press` logs "Ignoring request to press".
Merge pull request #203 from drothlis/log-press

stbt._X11Remote.press: Log keypress
stbt batch run: Add "-o" to specify output directory

This makes it easier to run "stbt batch run" as the target of an ssh
command. For example:

    ssh server.example.com stbt batch run -o /var/stbt-results/ ...

I didn't want to use "-C" a la make/tar/git because one day we might
want to use that to specify the input directory to save typing long test
pathnames. (`stbt batch run -C /long/path/to/tests test1.py test2.py`
instead of: `stbt batch run /long/path/to/tests/test1.py
/long/path/to/tests/test2.py`.)

"stbt batch run" doesn't output a single file so I think it's safe to
use "-o" for the output directory command-line option.

This doesn't support spaces in the output directory name, due to a bug
in "stbt batch report".
Merge pull request #204 from drothlis/stbt-batch-run-output-dir

stbt batch run: Add "-o" to specify output directory
test_that_stbt_run_exits_on_ctrl_c: Increase timeout

It seems hard to believe that the "stbt run" process is scheduled 20
times before its parent process, but this was failing occasionally on
Travis.

If the test still fails on Travis with this increased timeout, we'll
know for sure that there's something else going wrong.
stbt batch run: Propagate exit status if running a single test

This enables using `stbt batch run` just like `stbt run`, but with calling
the hooks and producing the HTML report.
Merge pull request #206 from wmanley/stbt-batch-run-propagate-exit-status

stbt batch run: Propagate exit status if running a single test
API: Region: Add extend method

Often you will want to pass a `Region` to a stbt function, and that
`Region` be based on a `Region` returned from another method, but with
modifications.  `Region.extend()` makes this easy and convenient.

This is a dependency of stbt.match_text coming in a future commit.
API: Region: Add method `intersect()`

This makes it convenient to find out whether two regions overlap, and if
they do what the overlapping `Region` is.

This is a dependency of `match_text` added in a future commit.
Region: Check that we are constructing a valid Region

A debugging aid which was helpful to me when implementing `match_text`.
API: OCR: Add stbt.match_text()

`match_text` is intended to be used like `detect_match`, etc, but for
text.  You search for a specific piece of text and it returns extra
information including the bounding box of the detected text.

It uses the tesseract hOCR mode.  hOCR is an XHTML subset with additional
information embedded such as word locations.
Merge pull request #149 from wmanley/ocr-match-text

API: Add `stbt.match_text`
.travis.yml: Lock astroid to version 1.1.0

astroid is a library used by pylint. Since astroid 1.2.0 was released,
our `make check-pylint` on Travis fails with `StopIteration` and the
below stack trace while checking tests/test_ocr.py. See bug #42 in the
astroid bug tracker[1].

    File "/usr/local/bin/pylint", line 9, in <module>
      load_entry_point('pylint==1.1.0', 'console_scripts', 'pylint')()
    File "/usr/local/lib/python2.7/dist-packages/pylint/__init__.py", line 21, in run_pylint
      Run(sys.argv[1:])
    File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 1040, in __init__
      linter.check(args)
    File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 626, in check
      self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
    File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 712, in check_astroid_module
      walker.walk(astroid)
    File "/usr/local/lib/python2.7/dist-packages/pylint/utils.py", line 697, in walk
      self.walk(child)
    File "/usr/local/lib/python2.7/dist-packages/pylint/utils.py", line 694, in walk
      cb(astroid)
    File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/base.py", line 246, in visit_function
      self._check_redefinition(node.is_method() and 'method' or 'function', node)
    File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 670, in is_method
      return self.type != 'function' and isinstance(self.parent.frame(), Class)
    File "/usr/local/lib/python2.7/dist-packages/logilab/common/decorators.py", line 155, in __get__
      val = self.wrapped(inst)
    File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 536, in _function_type
      _type = _infer_decorator_callchain(node)
    File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 501, in _infer_decorator_callchain
      result = current.infer_call_result(current.parent).next()
    StopIteration

[1]: https://bitbucket.org/logilab/astroid/issue/42/pylint-with-astroid-120-fails-with
Refactor: Region: Change internal representation of `Region`

`Region` is now represented internally as (x, y, right, bottom) rather than
(x, y, width, height).  This gives us a way to represent regions which are
infinite, such as the region x < 5, y > 10.  This seems to be a more
natural representation anyway as most of out methods and uses use right and
bottom.

This is not intended as an externally visible change, although some details
may leak through the cracks.  These include:

* The string returned by `__repr__` lists right and bottom rather than
  width and height.  This is necessary as `repr` should be unambiguous.
* If you use subscripting to get at the internal representation of the
  `Region` (e.g. `region[2:]`) this will now return `right` and `bottom`.
API: Region: Add Region.ALL

`Region.ALL` represents the entire 2D frame from -∞ to +∞ in both the x
and y directions.  This is useful to pass to functions that take a
`region=` parameter to say that we want the whole frame considered.  This
is really quite nice as it behaves as you might expect with functions
such as `contains()`, `intersect()` and `extend()` without any special
casing.

In the 0.20 release the only public function which took a `region=`
parameter was `ocr()`.  In this case the parameter defaulted to `None`
meaning the whole frame.  It now defaults to `Region.ALL` with the same
meaning as before.  Passing `region=None` to `ocr()` is deprecated so in
the future we can change its meaning to mean the empty region consistent
with the return value of `Region.intersect()` and the region parameter
of `TextMatchResult` as returned from `match_text()`.