Create cursor object inside the with statement.
Merge pull request #767 from sophron/create-cursor-object-inside-the-with-statement

Create cursor object inside the with statement
Upgrade to pyelliptic version 1.5.5.
Merge pull request #768 from Renelvon/bump_pyelliptic

Upgrade pyelliptic to version 1.5.5.
Order imports according to PEP8.
Remove unused methods.

* Remove remove_peer, addCryptoPeer, _checkok, closed, get_guid,
  get_bitmessage_api, get_myself.
Remove unused argument from get_crypto_peer.
Dump connect_to_peers.
Merge pull request #765 from yagoulas/transport_initial_cleanup

Transport cleanup
Refactor network_util.

* Add leak-safe check_port. Replace special-purpose code.
  * Prefer ipv6 over ipv4 sockets.
  * Accept variable timeout.
* Use tornado.netutil to check for valid IPs.
* Abstract protocol in get_peer_url.
* Prefer importing modules than names.
* Purge exec flag from file.
* Other style fixes.
Refactor code in connection.py.

* Drop unused peer_alive attribute.
* Replace bare except clause.
* Drop unused PeerConnection.responses_received.
* Refactor PeerConnection.create_zmq_socket.
  * Allow it to raise an exception; we are catching it elsewhere.
  * Make it a private function.
* Refactor PeerConnection.send_raw.
  * Make failure cases stand out.
  * Do not compress until ready to send.
* Make failure cases stand out in CryptoPeerConnection.start_handshake.
* Rewrite CryptoPeerConnection.check_port to use network_util.
* Shorten CryptoPeerConnection.sign.
* Straighten CryptoPeerConnection.encrypt.
* Refactor CryptoPeerConnection.send.
  * Make failure cases stand out.
  * Guard against encrypt returning False.
* Remove PeerListener.cleanup_context. PeerListener no longer manages
  it own zmq.Context. Purge any references.
* Drop PeerListener.stop.
  * Do not destroy global context arbitrarily.
* Straighten PeerListener.listen.
* Remove unused import.
Use network_util utilities in DHT.

* Remove comment referring cleanup_context.
Turn TransportLayer.shutdown into abstract method.