Removing platform dependency note from process module

Removing comment that sets the wrong expectations of the process module's
capabilities. It needs to be platform independent since it's used to run our
integ tests, and when it isn't that's a bug. That said, Windows is
unfortunately having trouble with it at present...

https://trac.torproject.org/5493
https://trac.torproject.org/5783
Helper function to only run tests once

Adding a helper function to skip tests if they've been run before. This is
needed because some of our tests take a long time to run and are uneffected by
testing targets, so there's no point in wasting time on running them
repeatedly.
Replacing enums with class instances for connect_* functions

The connect_port and connect_socket_file convenience functions accept a
controller type that we would like to return. I had been using an enum for this
argument, but this means that we both (a) need to manually update it when
adding controllers and (b) can't recognize controller the user makes.

Replacing this with a class instance, like what TorCtl does. Tested by running
against a script for printing BW events.
Included last tor warning or error in launch_tor exceptions

Adding the last tor waring or error message that's probably useful for figuring
out the reason why tor failed to launch.
Removing GETINFO version queries from integ tests

Sathyanarayanan spotted a couple points in our integ tests where we make
'GETINFO version' queries, then compare against the parsed tor version. This
es no bueno because the parsed version just contains what, according to the
version-spec, is the version and the getinfo query includes extra data like
the git commit id it came from.

This is actually an issue we encountered before and was fixed. However, since
then these queries slipped back into new tests since they seem like an easy
way of exercising a socket. Oops. :)

Tested by checking out the git commit that gsathya is using (ef0bc7f), then
running stem's integ tests against that.

This fixes ticket 5918 and might address 5917 too (I'm not sure why the later
is hanging - that's not happening for me though the test did have an error).
Utilising metrics descriptor type annotations

Using the @type annotations added by Karsten to the metrics descriptors as per
ticket 5651.
Adding separate funtion for launching tor with tmp torrc

Like Vidalia, adding a function that creates a torrc, launches tor with it,
then removes it from disk. This is preferable to using the commandline
arguments since the those shouldn't be used for substantial data nor the hashed
password.

This replaces launch_tor()'s options argument, though I added a more genral
args replacement that can be used to do the same if the user wants.
Disabling launch_tor timeout when on windows

On windows the python signal module lacks a SIGALRM attribute, breaking
launch_tor. Disabling timeouts on windows to avoid this issue - ideally we
should find an alternative method for timeing out the function on windows but
that can wait.

Caught by pythonirc101. Issue is discussed on...
https://trac.torproject.org/projects/tor/ticket/5783
Stating runtime when launch_tor timeout test fails

Just had a transient testing failure from test_launch_tor_with_timeout. There's
nothing to go on since we don't even know how long the test took, so providing
that information on failure. Might need to mess with the bounds a bit if this
happens again.
Citing ticket 4817 in related pydocs

The pydocs warn users of authenticate_cookie and authenticate_password that we
can't reliably differentiate certain failures. Citing the related ticket.
Supporting bridge descriptor's router-digest field

Scrubbed bridge server and extra-info descriptors will soon have a
'router-digest' line which contains the server digest. This is a value that we
can't calculate for ourselves because, of course, the descriptor's contents
have been modified.

I'm flagging this as being a required field. This does not yet parse it in
extra-info descriptors since it neither has a digest() method nor did I realize
that bridge extra-info descriptors were special.
Removing expectation that bridge nicknames are scrubbed

Karsten plans to stop scrubbing bridge descriptor nicknames, so removing that
expectation from the 'is_scrubbed()' method.
Validate that signing key hash matches fingerprint

When parsing server descriptors checking that their fingerprints match a hash
of their signing key as part of validation. This requires the rsa module which
is neither built in, nor is it packaged for debian distros. Installation of it
is easy, but requires pip or easy-install. Instructions are available at...
http://stuvel.eu/files/python-rsa-doc/installation.html

It looks like python's builtin crypto module might be capable of doing this as
well...
http://stackoverflow.com/questions/5000434/python-rsa-library
https://www.dlitz.net/software/pycrypto/api/current/Crypto.PublicKey.RSA._RSAobj-class.html#exportKey

However, those instructions include usage of a private member and the function
that they suggest dosn't exist on my system (python 2.7.1), so I feel pretty
justified in saying "the pycrypto builtin is crap for this use case, and
patches welcome if someone can figure out how to make it work".

All credit for this patch goes to Beck, who's been diving into the descriptor
crypto on...
https://trac.torproject.org/projects/tor/ticket/5810
Minor error in logged message

s/server/descriptor
Adding Controller class

Making a class for the general controller. As a todo comment mentiond, moving
the from_port/from_socket_file helper functions there and revising the tests to
reflect that.
Implementing Controller.get_info

Implementation and testing (both unit and a little integ) for GETINFO queries.
There's still several todo notes to clean up, but the method itself is done.
Moving tor response classes into their own module

As we add more response classes it'll be messy to sprinkle them all about the
codebase. Making a single 'stem.response' module that'll contain them all.
These could probably do with some more love so I'll next see if I can make them
any tidier.
Single retry for socket connection

I just had integ tests fail due to an interrupt while trying to connect to the
tor control socket. This is the first time that I've seen it, so this isn't
much of a concern, but connecting to a socket is idempotent so we can do with
retrying it once if we fail.
Adding an is_ok() method to controller responses

Method added by Ravi during his safecookie work. Stealing it a little early
since I want it for refactoring that I'm doing.
Being more anal about 'OK' status checking

Refusing to parse messages that lack a 250 response on all lines, and checking
for a 'OK' status on the last line (and only the last line).