[tor-commits] [stem/master] Moving attribute enums to top level module

atagar at torproject.org atagar at torproject.org
Mon Dec 3 02:35:44 UTC 2012


commit c96c76ce16d42aeef6641bfeaaf937673934dc5c
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Nov 18 12:55:52 2012 -0800

    Moving attribute enums to top level module
    
    Enumerations for our event attributes don't really belong in the control
    module. They're a bit more like our exceptions in that they're a data type that
    might be used in multiple spots. Hence moving the enums to live with them.
---
 docs/api/control.rst         |    4 +-
 stem/__init__.py             |  285 ++++++++++++++++++++++++++++++++++++++++++
 stem/control.py              |  274 ----------------------------------------
 stem/response/events.py      |   41 +++---
 test/unit/response/events.py |   10 +--
 5 files changed, 309 insertions(+), 305 deletions(-)

diff --git a/docs/api/control.rst b/docs/api/control.rst
index 0a17d9e..4301374 100644
--- a/docs/api/control.rst
+++ b/docs/api/control.rst
@@ -3,8 +3,8 @@ Controller
 
 .. automodule:: stem.control
 
-Exceptions
-----------
+Exceptions and Attribute Enums
+------------------------------
 
 .. automodule:: stem
 
diff --git a/stem/__init__.py b/stem/__init__.py
index 961bc48..c27df43 100644
--- a/stem/__init__.py
+++ b/stem/__init__.py
@@ -13,6 +13,179 @@ Library for working with the tor process.
     |     +- InvalidArguments - Invalid request parameters.
     +- SocketError - Communication with the socket failed.
        +- SocketClosed - Socket has been shut down.
+
+.. data:: CircStatus (enum)
+  
+  Statuses that a circuit can be in. Tor may provide statuses not in this enum.
+  
+  ============ ===========
+  CircStatus   Description
+  ============ ===========
+  **LAUNCHED** new circuit was created
+  **BUILT**    circuit finished being created and can accept traffic
+  **EXTENDED** circuit has been extended by a hop
+  **FAILED**   circuit construction failed
+  **CLOSED**   circuit has been closed
+  ============ ===========
+
+.. data:: CircBuildFlag (enum)
+  
+  Attributes about how a circuit is built. These were introduced in tor version
+  0.2.3.11. Tor may provide flags not in this enum.
+  
+  ================= ===========
+  CircBuildFlag     Description
+  ================= ===========
+  **ONEHOP_TUNNEL** single hop circuit to fetch directory information
+  **IS_INTERNAL**   circuit that won't be used for client traffic
+  **NEED_CAPACITY** circuit only includes high capacity relays
+  **NEED_UPTIME**   circuit only includes relays with a high uptime
+  ================= ===========
+
+.. data:: CircPurpose (enum)
+  
+  Description of what a circuit is intended for. These were introduced in tor
+  version 0.2.1.6. Tor may provide purposes not in this enum.
+  
+  ==================== ===========
+  CircPurpose          Description
+  ==================== ===========
+  **GENERAL**          client traffic or fetching directory information
+  **HS_CLIENT_INTRO**  client side introduction point for a hidden service circuit
+  **HS_CLIENT_REND**   client side hidden service rendezvous circuit
+  **HS_SERVICE_INTRO** server side introduction point for a hidden service circuit
+  **HS_SERVICE_REND**  server side hidden service rendezvous circuit
+  **TESTING**          testing to see if we're reachable, so we can be used as a relay
+  **CONTROLLER**       circuit that was built by a controller
+  ==================== ===========
+
+.. data:: CircClosureReason (enum)
+  
+  Reason that a circuit is being closed or failed to be established. Tor may
+  provide purposes not in this enum.
+  
+  ========================= ===========
+  CircClosureReason         Description
+  ========================= ===========
+  **NONE**                  no reason given
+  **TORPROTOCOL**           violation in the tor protocol
+  **INTERNAL**              internal error
+  **REQUESTED**             requested by the client via a TRUNCATE command
+  **HIBERNATING**           relay is presently hibernating
+  **RESOURCELIMIT**         relay is out of memory, sockets, or circuit IDs
+  **CONNECTFAILED**         unable to contact the relay
+  **OR_IDENTITY**           relay had the wrong OR identification
+  **OR_CONN_CLOSED**        connection failed after being established
+  **FINISHED**              circuit has expired (see tor's MaxCircuitDirtiness config option)
+  **TIMEOUT**               circuit construction timed out
+  **DESTROYED**             circuit unexpectedly closed
+  **NOPATH**                not enough relays to make a circuit
+  **NOSUCHSERVICE**         requested hidden service does not exist
+  **MEASUREMENT_EXPIRED**   unknown (https://trac.torproject.org/7506)
+  ========================= ===========
+
+.. data:: HiddenServiceState (enum)
+  
+  State that a hidden service circuit can have. These were introduced in tor
+  version 0.2.3.11. Tor may provide states not in this enum.
+  
+  Enumerations fall into four groups based on their prefix...
+  
+  ======= ===========
+  Prefix  Description
+  ======= ===========
+  HSCI_*  client-side introduction-point
+  HSCR_*  client-side rendezvous-point
+  HSSI_*  service-side introduction-point
+  HSSR_*  service-side rendezvous-point
+  ======= ===========
+  
+  ============================= ===========
+  HiddenServiceState            Description
+  ============================= ===========
+  **HSCI_CONNECTING**           connecting to the introductory point
+  **HSCI_INTRO_SENT**           sent INTRODUCE1 and awaiting a reply
+  **HSCI_DONE**                 received a reply, circuit is closing
+  **HSCR_CONNECTING**           connecting to the introductory point
+  **HSCR_ESTABLISHED_IDLE**     rendezvous-point established, awaiting an introduction
+  **HSCR_ESTABLISHED_WAITING**  introduction received, awaiting a rend
+  **HSCR_JOINED**               connected to the hidden service
+  **HSSI_CONNECTING**           connecting to the introductory point
+  **HSSI_ESTABLISHED**          established introductory point
+  **HSSR_CONNECTING**           connecting to the introductory point
+  **HSSR_JOINED**               connected to the rendezvous-point
+  ============================= ===========
+
+.. data:: StreamStatus (enum)
+  
+  State that a stream going through tor can have. Tor may provide states not in
+  this enum.
+  
+  ================= ===========
+  StreamStatus      Description
+  ================= ===========
+  **NEW**           request for a new connection
+  **NEWRESOLVE**    request to resolve an address
+  **REMAP**         address is being re-mapped to another
+  **SENTCONNECT**   sent a connect cell along a circuit
+  **SENTRESOLVE**   sent a resolve cell along a circuit
+  **SUCCEEDED**     stream has been established
+  **FAILED**        stream is detached, and won't be re-established
+  **DETACHED**      stream is detached, but might be re-established
+  **CLOSED**        stream has closed
+  ================= ===========
+
+.. data:: StreamClosureReason (enum)
+  
+  Reason that a stream is being closed or failed to be established. Tor may
+  provide purposes not in this enum.
+  
+  ===================== ===========
+  StreamClosureReason   Description
+  ===================== ===========
+  **MISC**              none of the following reasons
+  **RESOLVEFAILED**     unable to resolve the hostname
+  **CONNECTREFUSED**    remote host refused the connection
+  **EXITPOLICY**        rejected by the exit due to its exit policy
+  **DESTROY**           circuit is being shut down
+  **DONE**              connection has been closed
+  **TIMEOUT**           connection timed out
+  **NOROUTE**           routing error while contacting the destinaiton
+  **HIBERNATING**       relay is hibernating
+  **INTERNAL**          internal error
+  **RESOURCELIMIT**     relay has insufficient resources to service the request
+  **CONNRESET**         connection has been reset
+  **TORPROTOCOL**       violation in the tor protocol
+  **NOTDIRECTORY**      directory information requested from a relay that isn't mirroring it
+  **END**               endpoint has sent a RELAY_END cell
+  **PRIVATE_ADDR**      endpoint was a private address (127.0.0.1, 10.0.0.1, etc)
+  ===================== ===========
+
+.. data:: StreamSource (enum)
+  
+  Cause of a stream being remapped to another address.
+  
+  ============= ===========
+  StreamSource  Description
+  ============= ===========
+  **CACHE**     tor is remapping because of a cached answer
+  **EXIT**      exit relay requested the remap
+  ============= ===========
+
+.. data:: StreamPurpose (enum)
+  
+  Purpsoe of the stream. This is only provided with new streams and tor may
+  provide purposes not in this enum.
+  
+  ================= ===========
+  StreamPurpose     Description
+  ================= ===========
+  **DIR_FETCH**     unknown (https://trac.torproject.org/7508)
+  **UPLOAD_DESC**   unknown (https://trac.torproject.org/7508)
+  **DNS_REQUEST**   unknown (https://trac.torproject.org/7508)
+  **USER**          unknown (https://trac.torproject.org/7508)
+  **DIRPORT_TEST**  unknown (https://trac.torproject.org/7508)
+  ================= ===========
 """
 
 __version__ = '0.0.1'
@@ -40,8 +213,19 @@ __all__ = [
   "InvalidArguments",
   "SocketError",
   "SocketClosed",
+  "CircStatus",
+  "CircBuildFlag",
+  "CircPurpose",
+  "CircClosureReason",
+  "HiddenServiceState",
+  "StreamStatus",
+  "StreamClosureReason",
+  "StreamSource",
+  "StreamPurpose",
 ]
 
+import stem.util.enum
+
 class ControllerError(Exception):
   "Base error for controller communication issues."
 
@@ -92,3 +276,104 @@ class SocketError(ControllerError):
 class SocketClosed(SocketError):
   "Control socket was closed before completing the message."
 
+CircStatus = stem.util.enum.UppercaseEnum(
+  "LAUNCHED",
+  "BUILT",
+  "EXTENDED",
+  "FAILED",
+  "CLOSED",
+)
+
+CircBuildFlag = stem.util.enum.UppercaseEnum(
+  "ONEHOP_TUNNEL",
+  "IS_INTERNAL",
+  "NEED_CAPACITY",
+  "NEED_UPTIME",
+)
+
+CircPurpose = stem.util.enum.UppercaseEnum(
+  "GENERAL",
+  "HS_CLIENT_INTRO",
+  "HS_CLIENT_REND",
+  "HS_SERVICE_INTRO",
+  "HS_SERVICE_REND",
+  "TESTING",
+  "CONTROLLER",
+)
+
+CircClosureReason = stem.util.enum.UppercaseEnum(
+  "NONE",
+  "TORPROTOCOL",
+  "INTERNAL",
+  "REQUESTED",
+  "HIBERNATING",
+  "RESOURCELIMIT",
+  "CONNECTFAILED",
+  "OR_IDENTITY",
+  "OR_CONN_CLOSED",
+  "FINISHED",
+  "TIMEOUT",
+  "DESTROYED",
+  "NOPATH",
+  "NOSUCHSERVICE",
+  "MEASUREMENT_EXPIRED",
+)
+
+HiddenServiceState = stem.util.enum.UppercaseEnum(
+  "HSCI_CONNECTING",
+  "HSCI_INTRO_SENT",
+  "HSCI_DONE",
+  "HSCR_CONNECTING",
+  "HSCR_ESTABLISHED_IDLE",
+  "HSCR_ESTABLISHED_WAITING",
+  "HSCR_JOINED",
+  "HSSI_CONNECTING",
+  "HSSI_ESTABLISHED",
+  "HSSR_CONNECTING",
+  "HSSR_JOINED",
+)
+
+StreamStatus = stem.util.enum.UppercaseEnum(
+  "NEW",
+  "NEWRESOLVE",
+  "REMAP",
+  "SENTCONNECT",
+  "SENTRESOLVE",
+  "SUCCEEDED",
+  "FAILED",
+  "DETACHED",
+  "CLOSED",
+)
+
+StreamClosureReason = stem.util.enum.UppercaseEnum(
+  "MISC",
+  "RESOLVEFAILED",
+  "CONNECTREFUSED",
+  "EXITPOLICY",
+  "DESTROY",
+  "DONE",
+  "TIMEOUT",
+  "NOROUTE",
+  "HIBERNATING",
+  "INTERNAL",
+  "RESOURCELIMIT",
+  "CONNRESET",
+  "TORPROTOCOL",
+  "NOTDIRECTORY",
+  "END",
+  "PRIVATE_ADDR",
+)
+
+StreamSource = stem.util.enum.UppercaseEnum(
+  "CACHE",
+  "EXIT",
+)
+
+StreamPurpose = stem.util.enum.UppercaseEnum(
+  "DIR_FETCH",
+  "UPLOAD_DESC",
+  "DNS_REQUEST",
+  "USER",
+  "DIRPORT_TEST",
+)
+
diff --git a/stem/control.py b/stem/control.py
index d0e8462..0ddc63c 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -80,179 +80,6 @@ providing its own for interacting at a higher level.
   **BW**      :class:`stem.response.events.BandwidthEvent`
   **CIRC**    :class:`stem.response.events.CircuitEvent`
   =========== ===========
-
-.. data:: CircStatus (enum)
-  
-  Statuses that a circuit can be in. Tor may provide statuses not in this enum.
-  
-  ============ ===========
-  CircStatus   Description
-  ============ ===========
-  **LAUNCHED** new circuit was created
-  **BUILT**    circuit finished being created and can accept traffic
-  **EXTENDED** circuit has been extended by a hop
-  **FAILED**   circuit construction failed
-  **CLOSED**   circuit has been closed
-  ============ ===========
-
-.. data:: CircBuildFlag (enum)
-  
-  Attributes about how a circuit is built. These were introduced in tor version
-  0.2.3.11. Tor may provide flags not in this enum.
-  
-  ================= ===========
-  CircBuildFlag     Description
-  ================= ===========
-  **ONEHOP_TUNNEL** single hop circuit to fetch directory information
-  **IS_INTERNAL**   circuit that won't be used for client traffic
-  **NEED_CAPACITY** circuit only includes high capacity relays
-  **NEED_UPTIME**   circuit only includes relays with a high uptime
-  ================= ===========
-
-.. data:: CircPurpose (enum)
-  
-  Description of what a circuit is intended for. These were introduced in tor
-  version 0.2.1.6. Tor may provide purposes not in this enum.
-  
-  ==================== ===========
-  CircPurpose          Description
-  ==================== ===========
-  **GENERAL**          client traffic or fetching directory information
-  **HS_CLIENT_INTRO**  client side introduction point for a hidden service circuit
-  **HS_CLIENT_REND**   client side hidden service rendezvous circuit
-  **HS_SERVICE_INTRO** server side introduction point for a hidden service circuit
-  **HS_SERVICE_REND**  server side hidden service rendezvous circuit
-  **TESTING**          testing to see if we're reachable, so we can be used as a relay
-  **CONTROLLER**       circuit that was built by a controller
-  ==================== ===========
-
-.. data:: CircClosureReason (enum)
-  
-  Reason that a circuit is being closed or failed to be established. Tor may
-  provide purposes not in this enum.
-  
-  ========================= ===========
-  CircClosureReason         Description
-  ========================= ===========
-  **NONE**                  no reason given
-  **TORPROTOCOL**           violation in the tor protocol
-  **INTERNAL**              internal error
-  **REQUESTED**             requested by the client via a TRUNCATE command
-  **HIBERNATING**           relay is presently hibernating
-  **RESOURCELIMIT**         relay is out of memory, sockets, or circuit IDs
-  **CONNECTFAILED**         unable to contact the relay
-  **OR_IDENTITY**           relay had the wrong OR identification
-  **OR_CONN_CLOSED**        connection failed after being established
-  **FINISHED**              circuit has expired (see tor's MaxCircuitDirtiness config option)
-  **TIMEOUT**               circuit construction timed out
-  **DESTROYED**             circuit unexpectedly closed
-  **NOPATH**                not enough relays to make a circuit
-  **NOSUCHSERVICE**         requested hidden service does not exist
-  **MEASUREMENT_EXPIRED**   unknown (https://trac.torproject.org/7506)
-  ========================= ===========
-
-.. data:: HiddenServiceState (enum)
-  
-  State that a hidden service circuit can have. These were introduced in tor
-  version 0.2.3.11. Tor may provide states not in this enum.
-  
-  Enumerations fall into four groups based on their prefix...
-  
-  ======= ===========
-  Prefix  Description
-  ======= ===========
-  HSCI_*  client-side introduction-point
-  HSCR_*  client-side rendezvous-point
-  HSSI_*  service-side introduction-point
-  HSSR_*  service-side rendezvous-point
-  ======= ===========
-  
-  ============================= ===========
-  HiddenServiceState            Description
-  ============================= ===========
-  **HSCI_CONNECTING**           connecting to the introductory point
-  **HSCI_INTRO_SENT**           sent INTRODUCE1 and awaiting a reply
-  **HSCI_DONE**                 received a reply, circuit is closing
-  **HSCR_CONNECTING**           connecting to the introductory point
-  **HSCR_ESTABLISHED_IDLE**     rendezvous-point established, awaiting an introduction
-  **HSCR_ESTABLISHED_WAITING**  introduction received, awaiting a rend
-  **HSCR_JOINED**               connected to the hidden service
-  **HSSI_CONNECTING**           connecting to the introductory point
-  **HSSI_ESTABLISHED**          established introductory point
-  **HSSR_CONNECTING**           connecting to the introductory point
-  **HSSR_JOINED**               connected to the rendezvous-point
-  ============================= ===========
-
-.. data:: StreamStatus (enum)
-  
-  State that a stream going through tor can have. Tor may provide states not in
-  this enum.
-  
-  ================= ===========
-  StreamStatus      Description
-  ================= ===========
-  **NEW**           request for a new connection
-  **NEWRESOLVE**    request to resolve an address
-  **REMAP**         address is being re-mapped to another
-  **SENTCONNECT**   sent a connect cell along a circuit
-  **SENTRESOLVE**   sent a resolve cell along a circuit
-  **SUCCEEDED**     stream has been established
-  **FAILED**        stream is detached, and won't be re-established
-  **DETACHED**      stream is detached, but might be re-established
-  **CLOSED**        stream has closed
-  ================= ===========
-
-.. data:: StreamClosureReason (enum)
-  
-  Reason that a stream is being closed or failed to be established. Tor may
-  provide purposes not in this enum.
-  
-  ===================== ===========
-  StreamClosureReason   Description
-  ===================== ===========
-  **MISC**              none of the following reasons
-  **RESOLVEFAILED**     unable to resolve the hostname
-  **CONNECTREFUSED**    remote host refused the connection
-  **EXITPOLICY**        rejected by the exit due to its exit policy
-  **DESTROY**           circuit is being shut down
-  **DONE**              connection has been closed
-  **TIMEOUT**           connection timed out
-  **NOROUTE**           routing error while contacting the destinaiton
-  **HIBERNATING**       relay is hibernating
-  **INTERNAL**          internal error
-  **RESOURCELIMIT**     relay has insufficient resources to service the request
-  **CONNRESET**         connection has been reset
-  **TORPROTOCOL**       violation in the tor protocol
-  **NOTDIRECTORY**      directory information requested from a relay that isn't mirroring it
-  **END**               endpoint has sent a RELAY_END cell
-  **PRIVATE_ADDR**      endpoint was a private address (127.0.0.1, 10.0.0.1, etc)
-  ===================== ===========
-
-.. data:: StreamSource (enum)
-  
-  Cause of a stream being remapped to another address.
-  
-  ============= ===========
-  StreamSource  Description
-  ============= ===========
-  **CACHE**     tor is remapping because of a cached answer
-  **EXIT**      exit relay requested the remap
-  ============= ===========
-
-.. data:: StreamPurpose (enum)
-  
-  Purpsoe of the stream. This is only provided with new streams and tor may
-  provide purposes not in this enum.
-  
-  ================= ===========
-  StreamPurpose     Description
-  ================= ===========
-  **DIR_FETCH**     unknown (https://trac.torproject.org/7508)
-  **UPLOAD_DESC**   unknown (https://trac.torproject.org/7508)
-  **DNS_REQUEST**   unknown (https://trac.torproject.org/7508)
-  **USER**          unknown (https://trac.torproject.org/7508)
-  **DIRPORT_TEST**  unknown (https://trac.torproject.org/7508)
-  ================= ===========
 """
 
 from __future__ import with_statement
@@ -303,107 +130,6 @@ EventType = stem.util.enum.UppercaseEnum(
   "CIRC_MINOR",
 )
 
-CircStatus = stem.util.enum.UppercaseEnum(
-  "LAUNCHED",
-  "BUILT",
-  "EXTENDED",
-  "FAILED",
-  "CLOSED",
-)
-
-CircBuildFlag = stem.util.enum.UppercaseEnum(
-  "ONEHOP_TUNNEL",
-  "IS_INTERNAL",
-  "NEED_CAPACITY",
-  "NEED_UPTIME",
-)
-
-CircPurpose = stem.util.enum.UppercaseEnum(
-  "GENERAL",
-  "HS_CLIENT_INTRO",
-  "HS_CLIENT_REND",
-  "HS_SERVICE_INTRO",
-  "HS_SERVICE_REND",
-  "TESTING",
-  "CONTROLLER",
-)
-
-CircClosureReason = stem.util.enum.UppercaseEnum(
-  "NONE",
-  "TORPROTOCOL",
-  "INTERNAL",
-  "REQUESTED",
-  "HIBERNATING",
-  "RESOURCELIMIT",
-  "CONNECTFAILED",
-  "OR_IDENTITY",
-  "OR_CONN_CLOSED",
-  "FINISHED",
-  "TIMEOUT",
-  "DESTROYED",
-  "NOPATH",
-  "NOSUCHSERVICE",
-  "MEASUREMENT_EXPIRED",
-)
-
-HiddenServiceState = stem.util.enum.UppercaseEnum(
-  "HSCI_CONNECTING",
-  "HSCI_INTRO_SENT",
-  "HSCI_DONE",
-  "HSCR_CONNECTING",
-  "HSCR_ESTABLISHED_IDLE",
-  "HSCR_ESTABLISHED_WAITING",
-  "HSCR_JOINED",
-  "HSSI_CONNECTING",
-  "HSSI_ESTABLISHED",
-  "HSSR_CONNECTING",
-  "HSSR_JOINED",
-)
-
-StreamStatus = stem.util.enum.UppercaseEnum(
-  "NEW",
-  "NEWRESOLVE",
-  "REMAP",
-  "SENTCONNECT",
-  "SENTRESOLVE",
-  "SUCCEEDED",
-  "FAILED",
-  "DETACHED",
-  "CLOSED",
-)
-
-StreamClosureReason = stem.util.enum.UppercaseEnum(
-  "MISC",
-  "RESOLVEFAILED",
-  "CONNECTREFUSED",
-  "EXITPOLICY",
-  "DESTROY",
-  "DONE",
-  "TIMEOUT",
-  "NOROUTE",
-  "HIBERNATING",
-  "INTERNAL",
-  "RESOURCELIMIT",
-  "CONNRESET",
-  "TORPROTOCOL",
-  "NOTDIRECTORY",
-  "END",
-  "PRIVATE_ADDR",
-)
-
-StreamSource = stem.util.enum.UppercaseEnum(
-  "CACHE",
-  "EXIT",
-)
-
-StreamPurpose = stem.util.enum.UppercaseEnum(
-  "DIR_FETCH",
-  "UPLOAD_DESC",
-  "DNS_REQUEST",
-  "USER",
-  "DIRPORT_TEST",
-)
-
 # Constant to indicate an undefined argument default. Usually we'd use None for
 # this, but users will commonly provide None as the argument so need something
 # else fairly unique...
diff --git a/stem/response/events.py b/stem/response/events.py
index 8a0e428..1b28eb3 100644
--- a/stem/response/events.py
+++ b/stem/response/events.py
@@ -1,5 +1,6 @@
 import re
 
+import stem
 import stem.control
 import stem.response
 
@@ -86,17 +87,17 @@ class CircuitEvent(Event):
   version 0.1.2.2.
   
   :var str id: circuit identifier
-  :var stem.control.CircStatus status: reported status for the circuit
+  :var stem.CircStatus status: reported status for the circuit
   :var tuple path: relays involved in the circuit, these are
     **(fingerprint, nickname)** tuples
-  :var tuple build_flags: :data:`~stem.control.CircBuildFlag` attributes
+  :var tuple build_flags: :data:`~stem.CircBuildFlag` attributes
     governing how the circuit is built
-  :var stem.control.CircPurpose purpose: purpose that the circuit is intended for
-  :var stem.control.HiddenServiceState hs_state: status if this is a hidden service circuit
+  :var stem.CircPurpose purpose: purpose that the circuit is intended for
+  :var stem.HiddenServiceState hs_state: status if this is a hidden service circuit
   :var str rend_query: circuit's rendezvous-point if this is hidden service related
   :var datetime created: time when the circuit was created or cannibalized
-  :var stem.control.CircClosureReason reason: reason for the circuit to be closed
-  :var stem.control.CircClosureReason remote_reason: remote side's reason for the circuit to be closed
+  :var stem.CircClosureReason reason: reason for the circuit to be closed
+  :var stem.CircClosureReason remote_reason: remote side's reason for the circuit to be closed
   """
   
   _POSITIONAL_ARGS = ("id", "status", "path")
@@ -130,29 +131,29 @@ class CircuitEvent(Event):
     
     unrecognized_msg = "CIRC event had an unrecognised %%s (%%s). Maybe a new addition to the control protocol? Full Event: '%s'" % self
     
-    if self.status and (not self.status in stem.control.CircStatus):
+    if self.status and (not self.status in stem.CircStatus):
       log_id = "event.circ.unknown_status.%s" % self.status
       log.log_once(log_id, log.INFO, unrecognized_msg % ('status', self.status))
     
     if self.build_flags:
       for flag in self.build_flags:
-        if not flag in stem.control.CircBuildFlag:
+        if not flag in stem.CircBuildFlag:
           log_id = "event.circ.unknown_build_flag.%s" % flag
           log.log_once(log_id, log.INFO, unrecognized_msg % ('build flag', flag))
     
-    if self.purpose and (not self.purpose in stem.control.CircPurpose):
+    if self.purpose and (not self.purpose in stem.CircPurpose):
       log_id = "event.circ.unknown_purpose.%s" % self.purpose
       log.log_once(log_id, log.INFO, unrecognized_msg % ('purpose', self.purpose))
     
-    if self.hs_state and (not self.hs_state in stem.control.HiddenServiceState):
+    if self.hs_state and (not self.hs_state in stem.HiddenServiceState):
       log_id = "event.circ.unknown_hs_state.%s" % self.hs_state
       log.log_once(log_id, log.INFO, unrecognized_msg % ('hidden service state', self.hs_state))
     
-    if self.reason and (not self.reason in stem.control.CircClosureReason):
+    if self.reason and (not self.reason in stem.CircClosureReason):
       log_id = "event.circ.unknown_reason.%s" % self.reason
       log.log_once(log_id, log.INFO, unrecognized_msg % ('reason', self.reason))
     
-    if self.remote_reason and (not self.remote_reason in stem.control.CircClosureReason):
+    if self.remote_reason and (not self.remote_reason in stem.CircClosureReason):
       log_id = "event.circ.unknown_remote_reason.%s" % self.remote_reason
       log.log_once(log_id, log.INFO, unrecognized_msg % ('remote reason', self.remote_reason))
 
@@ -161,18 +162,18 @@ class StreamEvent(Event):
   Event that indicates that a stream has changed.
   
   :var str id: stream identifier
-  :var stem.control.StreamStatus status: reported status for the stream
+  :var stem.StreamStatus status: reported status for the stream
   :var str circ_id: circuit that the stream is attached to
   :var str target: destination of the stream
   :var str target_address: destination address (ip or hostname)
   :var int target_port: destination port
-  :var stem.control.StreamClosureReason reason: reason for the stream to be closed
-  :var stem.control.StreamClosureReason remote_reason: remote side's reason for the stream to be closed
-  :var stem.control.StreamSource source: origin of the REMAP request
+  :var stem.StreamClosureReason reason: reason for the stream to be closed
+  :var stem.StreamClosureReason remote_reason: remote side's reason for the stream to be closed
+  :var stem.StreamSource source: origin of the REMAP request
   :var str source_addr: requester of the connection
   :var str source_address: requester address (ip or hostname)
   :var int source_port: requester port
-  :var stem.control.StreamPurpose purpose: purpose for the stream
+  :var stem.StreamPurpose purpose: purpose for the stream
   """
   
   _POSITIONAL_ARGS = ("id", "status", "circ_id", "target")
@@ -224,15 +225,15 @@ class StreamEvent(Event):
     
     unrecognized_msg = "STREAM event had an unrecognised %%s (%%s). Maybe a new addition to the control protocol? Full Event: '%s'" % self
     
-    if self.reason and (not self.reason in stem.control.StreamClosureReason):
+    if self.reason and (not self.reason in stem.StreamClosureReason):
       log_id = "event.stream.reason.%s" % self.reason
       log.log_once(log_id, log.INFO, unrecognized_msg % ('reason', self.reason))
     
-    if self.remote_reason and (not self.remote_reason in stem.control.StreamClosureReason):
+    if self.remote_reason and (not self.remote_reason in stem.StreamClosureReason):
       log_id = "event.stream.remote_reason.%s" % self.remote_reason
       log.log_once(log_id, log.INFO, unrecognized_msg % ('remote reason', self.remote_reason))
     
-    if self.purpose and (not self.purpose in stem.control.StreamPurpose):
+    if self.purpose and (not self.purpose in stem.StreamPurpose):
       log_id = "event.stream.purpose.%s" % self.purpose
       log.log_once(log_id, log.INFO, unrecognized_msg % ('purpose', self.purpose))
 
diff --git a/test/unit/response/events.py b/test/unit/response/events.py
index ac4a22f..3fe22de 100644
--- a/test/unit/response/events.py
+++ b/test/unit/response/events.py
@@ -10,15 +10,7 @@ import stem.response
 import stem.response.events
 import test.mocking as mocking
 
-from stem import ProtocolError
-from stem.control import CircStatus,\
-                         CircBuildFlag,\
-                         CircPurpose,\
-                         CircClosureReason,\
-                         StreamStatus,\
-                         StreamClosureReason,\
-                         StreamSource,\
-                         StreamPurpose
+from stem import * # enums and exceptions
 
 # CIRC events from tor v0.2.3.16
 





More information about the tor-commits mailing list