[Pkg-privacy-commits] [txtorcon] 01/03: Imported Upstream version 0.15.1

Iain R. Learmonth irl at moszumanska.debian.org
Mon Aug 15 10:16:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

irl pushed a commit to branch master
in repository txtorcon.

commit 08e1a59714114575fc41180df9007eec099c5814
Author: Iain R. Learmonth <irl at fsfe.org>
Date:   Mon Aug 15 10:44:41 2016 +0100

    Imported Upstream version 0.15.1
---
 Makefile                         |   2 +-
 PKG-INFO                         |   2 +-
 docs/README.rst                  | 226 ++++++++++++++++++++++++++++++++++++++-
 docs/release-checklist.rst       |  15 +--
 docs/releases.rst                |   6 ++
 examples/connect.py              |  27 -----
 examples/hidden_echo.py          |  16 ---
 examples/launch_tor_data_dir.py  |  43 --------
 examples/list_circuits.py        |  25 -----
 examples/multiple-socks-ports.py |  37 -------
 test/test_circuit.py             |  17 +++
 txtorcon.egg-info/PKG-INFO       |   2 +-
 txtorcon.egg-info/SOURCES.txt    |   5 -
 txtorcon.egg-info/top_level.txt  |   2 +-
 txtorcon/_metadata.py            |   4 +-
 txtorcon/circuit.py              |  24 ++---
 16 files changed, 274 insertions(+), 179 deletions(-)

diff --git a/Makefile b/Makefile
index 520bc72..8a940bf 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 .PHONY: test html counts coverage sdist clean install doc integration
 default: test
-VERSION = 0.15.0
+VERSION = 0.15.1
 
 test:
 	trial --reporter=text test
diff --git a/PKG-INFO b/PKG-INFO
index 112af9b..06fe8f9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: txtorcon
-Version: 0.15.0
+Version: 0.15.1
 Summary: 
     Twisted-based Tor controller client, with state-tracking and
     configuration abstractions.
diff --git a/docs/README.rst b/docs/README.rst
deleted file mode 120000
index 89a0106..0000000
--- a/docs/README.rst
+++ /dev/null
@@ -1 +0,0 @@
-../README.rst
\ No newline at end of file
diff --git a/docs/README.rst b/docs/README.rst
new file mode 100644
index 0000000..fca84b2
--- /dev/null
+++ b/docs/README.rst
@@ -0,0 +1,225 @@
+README
+======
+
+Documentation at https://txtorcon.readthedocs.org
+
+.. image:: https://travis-ci.org/meejah/txtorcon.png?branch=master
+    :target: https://www.travis-ci.org/meejah/txtorcon
+
+.. image:: https://coveralls.io/repos/meejah/txtorcon/badge.png
+    :target: https://coveralls.io/r/meejah/txtorcon
+
+.. image:: http://codecov.io/github/meejah/txtorcon/coverage.svg?branch=master
+    :target: http://codecov.io/github/meejah/txtorcon?branch=master
+
+.. image:: http://api.flattr.com/button/flattr-badge-large.png
+    :target: http://flattr.com/thing/1689502/meejahtxtorcon-on-GitHub
+
+
+quick start
+-----------
+
+For the impatient, there are two quick ways to install this::
+
+   $ pip install txtorcon
+
+... or, if you checked out or downloaded the source::
+
+   $ python setup.py install
+
+... or, better yet, use a virtualenv and the dev requirements::
+
+   $ virtualenv venv
+   $ ./venv/bin/pip install -e .[dev]
+
+For OSX, we can install txtorcon with the help of easy_install::
+
+   $ easy_install txtorcon
+
+To avoid installing, you can just add the base of the source to your
+PYTHONPATH::
+
+   $ export PYTHONPATH=`pwd`:$PYTHONPATH
+
+Then, you will want to explore the examples. Try "python
+examples/stream\_circuit\_logger.py" for instance.
+
+On Debian testing (jessie), or with wheezy-backports (big thanks to
+Lunar^ for all his packaging work) you can install easily::
+
+    $ apt-get install python-txtorcon
+
+You may also like `this asciinema demo <http://asciinema.org/a/5654>`_
+for an overview.
+
+Tor configuration
+-----------------
+
+You'll want to have the following options on in your ``torrc``::
+
+   CookieAuthentication 1
+   CookieAuthFileGroupReadable 1
+
+If you want to use unix sockets to speak to tor::
+
+   ControlSocketsGroupWritable 1
+   ControlSocket /var/run/tor/control
+
+The defaults used by py:meth:`txtorcon.build_local_tor_connection` will
+find a Tor on ``9051`` or ``/var/run/tor/control``
+
+
+overview
+--------
+
+txtorcon is a Twisted-based asynchronous Tor control protocol
+implementation. Twisted is an event-driven networking engine written
+in Python and Tor is an onion-routing network designed to improve
+people's privacy and anonymity on the Internet.
+
+The main abstraction of this library is txtorcon.TorControlProtocol
+which presents an asynchronous API to speak the Tor client protocol in
+Python. txtorcon also provides abstractions to track and get updates
+about Tor's state (txtorcon.TorState) and current configuration
+(including writing it to Tor or disk) in txtorcon.TorConfig, along
+with helpers to asynchronously launch slave instances of Tor including
+Twisted endpoint support.
+
+txtorcon runs all tests cleanly on:
+
+-  Debian "squeeze", "wheezy" and "jessie"
+-  OS X 10.4 (naif)
+-  OS X 10.8 (lukas lueg)
+-  OS X 10.9 (kurt neufeld)
+-  Fedora 18 (lukas lueg)
+-  FreeBSD 10 (enrique fynn) (**needed to install "lsof"**)
+-  RHEL6
+-  Reports from other OSes appreciated.
+
+If instead you want a synchronous (threaded) Python controller
+library, check out Stem at https://stem.torproject.org/
+
+
+quick implementation overview
+-----------------------------
+
+txtorcon provides a class to track Tor's current state -- such as
+details about routers, circuits and streams -- called
+txtorcon.TorState and an abstraction to the configuration values via
+txtorcon.TorConfig which provides attribute-style accessors to Tor's
+state (including making changes). txtorcon.TorState provides
+txtorcon.Router, txtorcon.Circuit and txtorcon.Stream objects which
+implement a listener interface so client code may receive updates (in
+real time) including Tor events.
+
+txtorcon uses **trial for unit-tests** and has 100% test-coverage --
+which is not to say I've covered all the cases, but nearly all of the
+code is at least exercised somehow by the unit tests.
+
+Tor itself is not required to be running for any of the tests. ohcount
+claims around 2000 lines of code for the core bit; around 4000
+including tests. About 37% comments in the not-test code.
+
+There are a few simple integration tests, based on Docker. More are
+always welcome!
+
+
+dependencies / requirements
+---------------------------
+
+- `twisted <http://twistedmatrix.com>`_: txtorcon should work with any
+   Twisted 11.1.0 or newer. Twisted 15.4.0+ works with Python3, and so
+   does txtorcon (if you find something broken on Py3 please file a bug).
+
+-  `GeoIP <https://www.maxmind.com/app/python>`_: **optional** provides location
+   information for ip addresses; you will want to download GeoLite City
+   from `MaxMind <https://www.maxmind.com/app/geolitecity>`_ or pay them
+   for more accuracy. Or use tor-geoip, which makes this sort-of
+   optional, in that we'll query Tor for the IP if the GeoIP database
+   doesn't have an answer. It also does ASN lookups if you installed that MaxMind database.
+
+-  development: `Sphinx <http://sphinx.pocoo.org/>`_ if you want to build the
+   documentation. In that case you'll also need something called
+   ``python-repoze.sphinx.autointerface`` (at least in Debian) to build
+   the Interface-derived docs properly.
+
+-  development: `coverage <http://nedbatchelder.com/code/coverage/>`_ to
+   run the code-coverage metrics, and Tox
+
+-  optional: GraphViz is used in the tests (and to generate state-machine
+   diagrams, if you like) but those tests are skipped if "dot" isn't
+   in your path
+
+.. BEGIN_INSTALL
+
+In any case, on a `Debian <http://www.debian.org/>`_ wheezy, squeeze or
+Ubuntu system, this should work::
+
+    apt-get install -y python-setuptools python-twisted python-ipaddr python-geoip graphviz tor
+    apt-get install -y python-sphinx python-repoze.sphinx.autointerface python-coverage # for development
+
+.. END_INSTALL
+
+Using pip this would be::
+
+    pip install Twisted ipaddr pygeoip
+    pip install GeoIP Sphinx repoze.sphinx.autointerface coverage  # for development
+
+or::
+
+    pip install -r requirements.txt
+    pip install -r dev-requirements.txt
+
+or for the bare minimum::
+
+    pip install Twisted  # will install zope.interface too
+
+
+documentation
+-------------
+
+It is likely that you will need to read at least some of
+`control-spec.txt <https://gitweb.torproject.org/torspec.git/blob/HEAD:/control-spec.txt>`_
+from the torspec git repository so you know what's being abstracted by
+this library.
+
+Run "make doc" to build the Sphinx documentation locally, or rely on
+ReadTheDocs https://txtorcon.readthedocs.org which builds each tagged
+release and the latest master.
+
+There is also a directory of examples/ scripts, which have inline
+documentation explaining their use.
+
+
+contact information
+-------------------
+
+For novelty value, the Web site (with built documentation and so forth)
+can be viewed via Tor at http://timaq4ygg2iegci7.onion although the
+code itself is hosted via git::
+
+    torsocks git clone git://timaq4ygg2iegci7.onion/txtorcon.git
+
+or::
+
+    git clone git://github.com/meejah/txtorcon.git
+
+You may contact me via ``meejah at meejah dot ca`` with GPG key
+`0xC2602803128069A7
+<http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC2602803128069A7>`_
+or see ``meejah.asc`` in the repository. The fingerprint is ``9D5A
+2BD5 688E CB88 9DEB CD3F C260 2803 1280 69A7``.
+
+It is often possible to contact me as ``meejah`` in #tor-dev on `OFTC
+<http://www.oftc.net/oftc/>`_ but be patient for replies (I do look at
+scrollback, so putting "meejah: " in front will alert my client).
+
+More conventionally, you may get the code at GitHub and documentation
+via ReadTheDocs:
+
+-  https://github.com/meejah/txtorcon
+-  https://txtorcon.readthedocs.org
+
+Please do **use the GitHub issue-tracker** to report bugs. Patches,
+pull-requests, comments and criticisms are all welcomed and
+appreciated.
diff --git a/docs/release-checklist.rst b/docs/release-checklist.rst
index 1a1f4ef..4373d8c 100644
--- a/docs/release-checklist.rst
+++ b/docs/release-checklist.rst
@@ -14,21 +14,24 @@ Release Checklist
    * blindly make links to the signatures
    * update heading, date
 
-* "make dist" and "make dist-sig" (if on signing machine)
+* on both signing-machine and build-machine shells:
+   * export VERSION=v0.15.1
+
+* (if on signing machine) "make dist" and "make dist-sig"
    * creates:
-     dist/txtorcon-X.Y.Z.tar.gz.asc
-     dist/txtorcon-X.Y.Z-py2-none-any.whl.asc
+     dist/txtorcon-${VERSION}.tar.gz.asc
+     dist/txtorcon-${VERSION}-py2-none-any.whl.asc
    * add the signatures to "signatues/"
    * add ALL FOUR files to dist/ (OR fix twine commands)
 
 * (if not on signing machine) do "make dist"
-  * scp dist/txtorcon-X.Y.Z.tar.gz dist/txtorcon-X.Y.Z-py2-none-any.whl signingmachine:
+  * scp dist/txtorcon-${VERSION}.tar.gz dist/txtorcon-${VERSION}-py2-none-any.whl signingmachine:
   * sign both, with .asc detached signatures (see Makefile for command)
   * copy signatures back to build machine, in dist/
   * double-check that they validate
 
 * generate sha256sum for each:
-     sha256sum dist/txtorcon-X.Y.Z.tar.gz dist/txtorcon-X.Y.Z-py2-none-any.whl
+     sha256sum dist/txtorcon-${VERSION}.tar.gz dist/txtorcon-${VERSION}-py2-none-any.whl
 
 * copy signature files to <root of dist>/signatures and commit them
   along with the above changes for versions, etc.
@@ -74,7 +77,7 @@ Release Checklist
 * copy release announcement to signing machine, update code
 
 * create signed tag
-   * git tag -s -u meejah at meejah.ca -F path/to/release-announcement-X-Y-Z vX.Y.Z
+   * git tag -s -u meejah at meejah.ca -F path/to/release-announcement-X-Y-Z v${VERSION}
 
 * copy dist/* files + signatures to hidden-service machine
 * copy them to the HTML build directory! (docs/_build/html/)
diff --git a/docs/releases.rst b/docs/releases.rst
index 280f82b..3f82ace 100644
--- a/docs/releases.rst
+++ b/docs/releases.rst
@@ -21,6 +21,12 @@ unreleased
 
 `git master <https://github.com/meejah/txtorcon>`_ *will likely become v0.16.0*
 
+v0.15.1
+-------
+
+ * `txtorcon-0.15.1.tar.gz <http://timaq4ygg2iegci7.onion/txtorcon-0.15.1.tar.gz>`_ (`PyPI <https://pypi.python.org/pypi/txtorcon/0.15.1>`_ (:download:`local-sig </../signatues/txtorcon-0.15.1.tar.gz.asc>` or `github-sig <https://github.com/meejah/txtorcon/blob/master/signatues/txtorcon-0.15.1.tar.gz.asc?raw=true>`_) (`source <https://github.com/meejah/txtorcon/archive/v0.15.1.tar.gz>`_)
+ * fix `issue 179 <https://github.com/meejah/txtorcon/issues/179>`_ with `Circuit.age`.
+
 
 v0.15.0
 -------
diff --git a/examples/connect.py b/examples/connect.py
deleted file mode 100644
index 50f3265..0000000
--- a/examples/connect.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-from twisted.internet.task import react
-from twisted.internet.defer import inlineCallbacks
-from twisted.internet.endpoints import TCP4ClientEndpoint
-import txtorcon
-
- at inlineCallbacks
-def main(reactor):
-    #ep = TCP4ClientEndpoint(reactor, "localhost", 9251)
-    ep = TCP4ClientEndpoint(reactor, "localhost", 9051)
-    # XXX nicer/better thing than "build_tor_connection" switching
-    # between returning two different objects depending on kwarg?
-    tor_protocol = yield txtorcon.connect(ep)
-    print(
-        "Connected to Tor {version}".format(
-            version=tor_protocol.version,
-        )
-    )
-    state = yield txtorcon.TorState.from_protocol(tor_protocol)
-    print("Tor state created. Circuits:")
-    for circuit in state.circuits.values():
-        print("  {circuit.id}: {circuit.path}".format(circuit=circuit))
-
-
-react(main)
diff --git a/examples/hidden_echo.py b/examples/hidden_echo.py
deleted file mode 100644
index b7b29c3..0000000
--- a/examples/hidden_echo.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from __future__ import print_function
-from twisted.internet import protocol, reactor, endpoints
-
-
-class Echo(protocol.Protocol):
-    def dataReceived(self, data):
-        self.transport.write(data)
-
-
-class EchoFactory(protocol.Factory):
-    def buildProtocol(self, addr):
-        return Echo()
-
-d = endpoints.serverFromString(reactor, "onion:1234").listen(EchoFactory())
-d.addCallback(lambda x: print(x.getHost()))
-reactor.run()
diff --git a/examples/launch_tor_data_dir.py b/examples/launch_tor_data_dir.py
deleted file mode 100644
index 651837c..0000000
--- a/examples/launch_tor_data_dir.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-
-# Launch a slave Tor by first making a TorConfig object.
-
-from sys import stdout
-from twisted.internet.task import react
-from twisted.internet.defer import inlineCallbacks
-import txtorcon
-
-
- at inlineCallbacks
-def main(reactor):
-    config = txtorcon.TorConfig()
-    config.OrPort = 1234
-    config.SocksPort = 9999
-    config.DataDirectory = 'boomblam'
-    try:
-        yield txtorcon.launch_tor(config, reactor, stdout=stdout)
-
-    except RuntimeError as e:
-        print "Error:", e
-        return
-
-    proto = config.protocol
-    print "Connected to Tor version", proto.version
-
-    state = yield txtorcon.TorState.from_protocol(proto)
-    print "This Tor has PID", state.tor_pid
-    print "This Tor has the following %d Circuits:" % len(state.circuits)
-    for c in state.circuits.values():
-        print c
-
-    print "Changing our config (SOCKSPort=9876)"
-    config.SOCKSPort = 9876
-    yield config.save()
-
-    print "Querying to see it changed:"
-    socksport = yield proto.get_conf("SOCKSPort")
-    print "SOCKSPort", socksport
-
-
-if __name__ == '__main__':
-    react(main)
diff --git a/examples/list_circuits.py b/examples/list_circuits.py
deleted file mode 100644
index 56f0860..0000000
--- a/examples/list_circuits.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python
-
-from twisted.internet.task import react
-from twisted.internet.defer import inlineCallbacks
-import txtorcon
-
-
- at inlineCallbacks
-def main(reactor):
-    state = yield txtorcon.build_local_tor_connection(reactor)
-    for circuit in state.circuits.values():
-        first_relay = circuit.path[0]
-        print "Circuit {} first hop: {}".format(circuit.id, first_relay.ip)
-#    x = yield state.protocol.get_info('desc/id/B69D45E2AC49A81E014425FF6E07C7435C9F89B0')
-#    x = yield state.protocol.get_info('desc/id/EAA0E6A2CD95F5AFF46CDF042623DE79C19E028A')
-    x = yield state.protocol.get_info('desc/id/EAA0E6A2CD95F5AFF46CDF042623DE79C19E028A')
-    print x
-
-    if False:
-        from guppy import hpy
-        print "heap:"
-        print hpy().heap()
-
-if __name__ == '__main__':
-    react(main)
diff --git a/examples/multiple-socks-ports.py b/examples/multiple-socks-ports.py
deleted file mode 100644
index 7d12daa..0000000
--- a/examples/multiple-socks-ports.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-
-# This connects to the system Tor (by default on control port 9151)
-# and adds a new hidden service configuration to it.
-
-from twisted.internet import reactor, defer
-from twisted.internet.endpoints import TCP4ClientEndpoint
-from twisted.internet.task import react
-
-import txtorcon
-
-
-def setup_failed(arg):
-    print "SETUP FAILED", arg
-    reactor.stop()
-
-
- at defer.inlineCallbacks
-def main(reactor):
-    # Connect to the system Tor. Since we leave the
-    # "build_state=True" default, this callbacks with a TorState
-    # object. Otherwise, it would be a TorControlProtocol object.
-    ep = TCP4ClientEndpoint(reactor, "localhost", 9051)
-    state = yield txtorcon.build_tor_connection(ep)
-
-    config = txtorcon.TorConfig(state.protocol)
-    yield config.post_bootstrap
-
-    if False:
-        config.socksport = [5432, 4321]
-    else:
-        config.socksport.append(5555)
-        config.socksport.append(4444)
-    yield config.save()
-
-# run the reactor main loop until the last callback from main() fires
-react(main)
diff --git a/test/test_circuit.py b/test/test_circuit.py
index 782e0c6..341e140 100644
--- a/test/test_circuit.py
+++ b/test/test_circuit.py
@@ -4,6 +4,7 @@ from twisted.trial import unittest
 from twisted.internet import defer, task
 from twisted.python.failure import Failure
 from zope.interface import implements
+from mock import patch
 
 from txtorcon import Circuit
 from txtorcon import build_timeout_circuit
@@ -105,6 +106,22 @@ class CircuitTests(unittest.TestCase):
         self.assertEquals(diff, 0)
         self.assertTrue(circuit.time_created is not None)
 
+    @patch('txtorcon.circuit.datetime')
+    def test_age_default(self, fake_datetime):
+        """
+        age() w/ defaults works properly
+        """
+        from datetime import datetime
+        now = datetime.fromtimestamp(60.0)
+        fake_datetime.return_value = now
+        fake_datetime.utcnow = Mock(return_value=now)
+        tor = FakeTorController()
+
+        circuit = Circuit(tor)
+        circuit._time_created = datetime.fromtimestamp(0.0)
+        self.assertEquals(circuit.age(), 60)
+        self.assertTrue(circuit.time_created is not None)
+
     def test_no_age_yet(self):
         """
         make sure age doesn't explode if there's no TIME_CREATED flag.
diff --git a/txtorcon.egg-info/PKG-INFO b/txtorcon.egg-info/PKG-INFO
index 112af9b..06fe8f9 100644
--- a/txtorcon.egg-info/PKG-INFO
+++ b/txtorcon.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: txtorcon
-Version: 0.15.0
+Version: 0.15.1
 Summary: 
     Twisted-based Tor controller client, with state-tracking and
     configuration abstractions.
diff --git a/txtorcon.egg-info/SOURCES.txt b/txtorcon.egg-info/SOURCES.txt
index e478445..4255aed 100644
--- a/txtorcon.egg-info/SOURCES.txt
+++ b/txtorcon.egg-info/SOURCES.txt
@@ -47,24 +47,19 @@ examples/add_hiddenservice_to_system_tor.py
 examples/attach_streams_by_country.py
 examples/circuit_failure_rates.py
 examples/circuit_for_next_stream.py
-examples/connect.py
 examples/disallow_streams_by_port.py
 examples/dump_config.py
 examples/ephemeral_endpoint.py
 examples/hello_darkweb.py
 examples/hidden-service-systemd.service
-examples/hidden_echo.py
 examples/launch_tor.py
 examples/launch_tor2web.py
-examples/launch_tor_data_dir.py
 examples/launch_tor_endpoint.py
 examples/launch_tor_endpoint2.py
 examples/launch_tor_with_hiddenservice.py
 examples/launch_tor_with_simplehttpd.py
-examples/list_circuits.py
 examples/minimal_endpoint.py
 examples/monitor.py
-examples/multiple-socks-ports.py
 examples/redirect_streams.py
 examples/schedule_bandwidth.py
 examples/stem_relay_descriptor.py
diff --git a/txtorcon.egg-info/top_level.txt b/txtorcon.egg-info/top_level.txt
index 1ba11e2..dc51759 100644
--- a/txtorcon.egg-info/top_level.txt
+++ b/txtorcon.egg-info/top_level.txt
@@ -1,2 +1,2 @@
-txtorcon
 twisted
+txtorcon
diff --git a/txtorcon/_metadata.py b/txtorcon/_metadata.py
index 476c613..3e2b124 100644
--- a/txtorcon/_metadata.py
+++ b/txtorcon/_metadata.py
@@ -1,6 +1,6 @@
-__version__ = '0.15.0'
+__version__ = '0.15.1'
 __author__ = 'meejah'
 __contact__ = 'meejah at meejah.ca'
 __url__ = 'https://github.com/meejah/txtorcon'
 __license__ = 'MIT'
-__copyright__ = 'Copyright 2012-2015'
+__copyright__ = 'Copyright 2012-2016'
diff --git a/txtorcon/circuit.py b/txtorcon/circuit.py
index 5166fc1..b72072f 100644
--- a/txtorcon/circuit.py
+++ b/txtorcon/circuit.py
@@ -6,7 +6,7 @@ from __future__ import unicode_literals
 from __future__ import with_statement
 
 import time
-import datetime
+from datetime import datetime
 
 from twisted.python.failure import Failure
 from twisted.python import log
@@ -39,16 +39,12 @@ class Circuit(object):
 
     :ivar state:
         contains a string from Tor describing the current state of the
-        stream. From control-spec.txt section 4.1.2, these are:
-            - NEW: New request to connect
-            - NEWRESOLVE: New request to resolve an address
-            - REMAP: Address re-mapped to another
-            - SENTCONNECT: Sent a connect cell along a circuit
-            - SENTRESOLVE: Sent a resolve cell along a circuit
-            - SUCCEEDED: Received a reply; stream established
-            - FAILED: Stream failed and not retriable
-            - CLOSED: Stream closed
-            - DETACHED: Detached from circuit; still retriable
+        stream. From control-spec.txt section 4.1.1, these are:
+           - LAUNCHED: circuit ID assigned to new circuit
+           - BUILT: all hops finished, can now accept streams
+           - EXTENDED: one more hop has been completed
+           - FAILED: circuit closed (was not built)
+           - CLOSED: circuit closed (was built)
 
     :ivar purpose:
         The reason this circuit was built. Values can currently be one
@@ -123,7 +119,7 @@ class Circuit(object):
             # strip off milliseconds
             t = self.flags['TIME_CREATED'].split('.')[0]
             tstruct = time.strptime(t, TIME_FORMAT)
-            self._time_created = datetime.datetime(*tstruct[:7])
+            self._time_created = datetime(*tstruct[:7])
         return self._time_created
 
     def listen(self, listener):
@@ -157,7 +153,7 @@ class Circuit(object):
         d.addCallback(close_command_is_queued)
         return self._closing_deferred
 
-    def age(self, now=datetime.datetime.utcnow()):
+    def age(self, now=None):
         """
         Returns an integer which is the difference in seconds from
         'now' to when this circuit was created.
@@ -166,6 +162,8 @@ class Circuit(object):
         """
         if not self.time_created:
             return None
+        if now is None:
+            now = datetime.utcnow()
         return (now - self.time_created).seconds
 
     def _create_flags(self, kw):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/txtorcon.git



More information about the Pkg-privacy-commits mailing list