commit ab553f54e70ea21d8bd117cf912e1b208417e5d5 Author: Damian Johnson atagar@torproject.org Date: Mon Jul 9 11:34:33 2012 -0700
Minor revisions for LOADCONF and prior cleanup --- stem/__init__.py | 2 +- stem/control.py | 3 ++- stem/descriptor/__init__.py | 2 +- stem/response/__init__.py | 2 +- stem/util/__init__.py | 2 +- stem/version.py | 1 + test/__init__.py | 2 +- test/integ/__init__.py | 2 +- test/integ/control/controller.py | 29 +++++++++++++++-------------- test/unit/__init__.py | 2 +- 10 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/stem/__init__.py b/stem/__init__.py index a2f00a1..faee5db 100644 --- a/stem/__init__.py +++ b/stem/__init__.py @@ -17,6 +17,6 @@ __all__ = [ "prereq", "process", "socket", - "version" + "version", ]
diff --git a/stem/control.py b/stem/control.py index f68183e..51804cc 100644 --- a/stem/control.py +++ b/stem/control.py @@ -19,6 +19,7 @@ interacting at a higher level. |- set_conf - sets the value of a configuration option |- reset_conf - reverts configuration options to their default values |- set_options - sets or resets the values of multiple configuration options + |- load_conf - loads configuration information as if it was in the torrc |- get_version - convenience method to get tor version |- authenticate - convenience method to authenticate the controller +- protocolinfo - convenience method to get the protocol info @@ -760,7 +761,7 @@ class Controller(BaseController): def load_conf(self, configtext): """ Sends the configuration text to Tor and loads it as if it has been read from - disk. + the torrc.
:param str configtext: the configuration text
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py index 2328bf5..f3b40c5 100644 --- a/stem/descriptor/__init__.py +++ b/stem/descriptor/__init__.py @@ -18,7 +18,7 @@ __all__ = [ "extrainfo_descriptor", "server_descriptor", "parse_file", - "Descriptor" + "Descriptor", ]
import os diff --git a/stem/response/__init__.py b/stem/response/__init__.py index 2d7f028..5a665b6 100644 --- a/stem/response/__init__.py +++ b/stem/response/__init__.py @@ -32,7 +32,7 @@ __all__ = [ "authchallenge", "convert", "ControlMessage", - "ControlLine" + "ControlLine", ]
import re diff --git a/stem/util/__init__.py b/stem/util/__init__.py index 6bc70e4..78fe9e1 100644 --- a/stem/util/__init__.py +++ b/stem/util/__init__.py @@ -10,6 +10,6 @@ __all__ = [ "proc", "system", "term", - "tor_tools" + "tor_tools", ]
diff --git a/stem/version.py b/stem/version.py index c63a92a..d0228b1 100644 --- a/stem/version.py +++ b/stem/version.py @@ -232,6 +232,7 @@ safecookie_req.greater_than(Version("0.2.3.13")) Requirement = stem.util.enum.Enum( ("AUTH_SAFECOOKIE", safecookie_req), ("GETINFO_CONFIG_TEXT", Version("0.2.2.7")), + ("LOADCONF", Version("0.2.1.1")), ("TORRC_CONTROL_SOCKET", Version("0.2.0.30")), ("TORRC_DISABLE_DEBUGGER_ATTACHMENT", Version("0.2.3.9")), ) diff --git a/test/__init__.py b/test/__init__.py index adb29e4..c0297aa 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -6,6 +6,6 @@ __all__ = [ "check_whitespace", "mocking", "output", - "runner" + "runner", ]
diff --git a/test/integ/__init__.py b/test/integ/__init__.py index ec9d1ca..3cc4a7f 100644 --- a/test/integ/__init__.py +++ b/test/integ/__init__.py @@ -9,6 +9,6 @@ __all__ = [ "process", "socket", "util", - "version" + "version", ]
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py index bcd76fb..857799d 100644 --- a/test/integ/control/controller.py +++ b/test/integ/control/controller.py @@ -274,25 +274,26 @@ class TestController(unittest.TestCase): """
if test.runner.require_control(self): return + elif test.runner.require_version(self, stem.version.Requirement.LOADCONF): return
runner = test.runner.get_runner()
with runner.get_tor_controller() as controller: oldconf = runner.get_torrc_contents()
- # invalid requests - self.assertRaises(stem.socket.InvalidRequest, controller.load_conf, "ContactInfo confloaded") try: - controller.load_conf("Blahblah blah") - except stem.socket.InvalidArguments, exc: - self.assertEqual(["Blahblah"], exc.arguments) - else: - self.fail() - - # valid config - controller.load_conf(runner.get_torrc_contents() + "\nContactInfo confloaded\n") - self.assertEqual("confloaded", controller.get_conf("ContactInfo")) - - # reload original valid config - controller.load_conf(oldconf) + # invalid requests + self.assertRaises(stem.socket.InvalidRequest, controller.load_conf, "ContactInfo confloaded") + try: + controller.load_conf("Blahblah blah") + self.fail() + except stem.socket.InvalidArguments, exc: + self.assertEqual(["Blahblah"], exc.arguments) + + # valid config + controller.load_conf(runner.get_torrc_contents() + "\nContactInfo confloaded\n") + self.assertEqual("confloaded", controller.get_conf("ContactInfo")) + finally: + # reload original valid config + controller.load_conf(oldconf)
diff --git a/test/unit/__init__.py b/test/unit/__init__.py index 6c77f6f..6bbec07 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -7,6 +7,6 @@ __all__ = [ "descriptor", "socket", "util", - "version" + "version", ]
tor-commits@lists.torproject.org