[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] Removing the last hints of TorCtl
commit 37f7e9597126392b326287bd6685d00d6627682b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Dec 16 20:06:04 2012 -0800
Removing the last hints of TorCtl
Dropping our TorCtl dependency and removing its last bits from the codebase.
There is definitely a lot of cleanup left to do, but we now no longer have that
dependency.
---
README | 6 +++---
armrc.sample | 2 +-
setup.py | 6 +-----
src/cli/controller.py | 3 +--
src/cli/headerPanel.py | 1 -
src/prereq.py | 44 +++-----------------------------------------
src/test.py | 2 +-
src/util/torConfig.py | 2 --
src/util/torTools.py | 36 +++++++++++-------------------------
9 files changed, 21 insertions(+), 81 deletions(-)
diff --git a/README b/README
index 05f18cb..e5676f7 100644
--- a/README
+++ b/README
@@ -20,7 +20,7 @@ An interview by Brenno Winter discussing the project is available at:
Requirements:
Python 2.5
-TorCtl (this is included with arm)
+Stem (this is included with arm)
Tor is running with an available control port. This means either...
... starting Tor with '--controlport <PORT>'
... or including 'ControlPort <PORT>' in your torrc
@@ -203,7 +203,7 @@ Layout:
popups.py - toolkit providing display popups
wizard.py - provides the relay setup wizard
- logPanel.py - (page 1) displays tor, arm, and torctl events
+ logPanel.py - (page 1) displays tor, arm, and stem events
configPanel.py - (page 3) editor panel for the tor configuration
torrcPanel.py - (page 4) displays torrc and validation
interpretorPanel.py - (page 5) interpretor for control port access
@@ -222,6 +222,6 @@ Layout:
textInput.py - expands the capabilities of text input fields
torConfig.py - functions for working with the torrc and config options
torInterpretor.py - provides a shell around raw control port access
- torTools.py - TorCtl wrapper, providing caching and derived information
+ torTools.py - Stem wrapper, providing caching and derived information
uiTools.py - helper functions for presenting the user interface
diff --git a/armrc.sample b/armrc.sample
index 1b264f7..5fb9564 100644
--- a/armrc.sample
+++ b/armrc.sample
@@ -271,7 +271,7 @@ log.startTime INFO
log.configEntryNotFound NONE
log.configEntryUndefined NOTICE
log.configEntryTypeError NOTICE
-log.torCtlPortClosed NOTICE
+log.stemPortClosed NOTICE
log.torEventTypeUnrecognized INFO
log.torPrefixPathInvalid NOTICE
log.procCallMade DEBUG
diff --git a/setup.py b/setup.py
index c94ac1f..7d035ed 100644
--- a/setup.py
+++ b/setup.py
@@ -90,11 +90,7 @@ if "install" in sys.argv:
except IOError, exc:
print "Unable to compress man page: %s" % exc
-# When installing we include a bundled copy of TorCtl. However, when creating
-# a deb we have a dependency on the python-torctl package instead:
-# http://packages.debian.org/unstable/main/python-torctl
-installPackages = ['arm', 'arm.cli', 'arm.cli.graphing', 'arm.cli.connections', 'arm.cli.menu', 'arm.util', 'arm.TorCtl', 'arm.stem']
-if isDebInstall: installPackages.remove('arm.TorCtl')
+installPackages = ['arm', 'arm.cli', 'arm.cli.graphing', 'arm.cli.connections', 'arm.cli.menu', 'arm.util', 'arm.stem']
setup(name='arm',
version=VERSION,
diff --git a/src/cli/controller.py b/src/cli/controller.py
index f01ef8a..de77e5a 100644
--- a/src/cli/controller.py
+++ b/src/cli/controller.py
@@ -22,7 +22,6 @@ import cli.graphing.connStats
import cli.graphing.resourceStats
import cli.connections.connPanel
-from TorCtl import TorCtl
from stem.control import Controller
from util import connections, conf, enum, hostnames, log, panel, sysTools, torConfig, torTools
@@ -564,7 +563,7 @@ def shutdownDaemons():
for panelImpl in control.getDaemonPanels(): panelImpl.stop()
for panelImpl in control.getDaemonPanels(): panelImpl.join()
- # joins on TorCtl event thread
+ # joins on stem threads
torTools.getConn().close()
# joins on utility daemon threads - this might take a moment since the
diff --git a/src/cli/headerPanel.py b/src/cli/headerPanel.py
index ce43e06..cf37ac1 100644
--- a/src/cli/headerPanel.py
+++ b/src/cli/headerPanel.py
@@ -19,7 +19,6 @@ import time
import curses
import threading
-import TorCtl.TorCtl
import stem
import stem.connection
diff --git a/src/prereq.py b/src/prereq.py
index f8ab73d..c01dfbd 100644
--- a/src/prereq.py
+++ b/src/prereq.py
@@ -12,23 +12,12 @@ import tempfile
# Library dependencies can be fetched on request. By default this is via
# the following mirrors with their sha256 signatures checked.
-TORCTL_ARCHIVE = "http://www.atagar.com/arm/resources/deps/11-06-16/torctl.tar.gz"
-TORCTL_SIG = "5460adb1394c368ba492cc33d6681618b3d3062b3f5f70b2a87520fc291701c3"
+#STEM_ARCHIVE = "http://www.atagar.com/arm/resources/deps/11-06-16/torctl.tar.gz"
+#STEM_SIG = "5460adb1394c368ba492cc33d6681618b3d3062b3f5f70b2a87520fc291701c3"
# optionally we can do an unverified fetch from the library's sources
STEM_REPO = "git://git.torproject.org/stem.git"
-def isTorCtlAvailable():
- """
- True if TorCtl is already available on the platform, false otherwise.
- """
-
- try:
- import TorCtl
- return True
- except ImportError:
- return False
-
def isStemAvailable():
"""
True if stem is already available on the platform, false otherwise.
@@ -40,30 +29,6 @@ def isStemAvailable():
except ImportError:
return False
-def promptTorCtlInstall():
- """
- Asks the user to install TorCtl. This returns True if it was installed and
- False otherwise (if it was either declined or failed to be fetched).
- """
-
- userInput = raw_input("Arm requires TorCtl to run, but it's unavailable. Would you like to install it? (y/n): ")
-
- # if user says no then terminate
- if not userInput.lower() in ("y", "yes"): return False
-
- # attempt to install TorCtl, printing the issue if unsuccessful
- try:
- fetchLibrary(TORCTL_ARCHIVE, TORCTL_SIG)
-
- if not isTorCtlAvailable():
- raise IOError("Unable to install TorCtl, sorry")
-
- print "TorCtl successfully installed"
- return True
- except IOError, exc:
- print exc
- return False
-
def promptStemInstall():
"""
Asks the user to install stem. This returns True if it was installed and
@@ -77,6 +42,7 @@ def promptStemInstall():
# attempt to install stem, printing the issue if unsuccessful
try:
+ #fetchLibrary(STEM_ARCHIVE, STEM_SIG)
installStem()
if not isStemAvailable():
@@ -163,10 +129,6 @@ if __name__ == '__main__':
print("arm requires python version 2.5 or greater\n")
sys.exit(1)
- if not isTorCtlAvailable():
- isInstalled = promptTorCtlInstall()
- if not isInstalled: sys.exit(1)
-
if not isStemAvailable():
isInstalled = promptStemInstall()
if not isInstalled: sys.exit(1)
diff --git a/src/test.py b/src/test.py
index af80879..7129120 100644
--- a/src/test.py
+++ b/src/test.py
@@ -23,7 +23,7 @@ conn = None
while True:
userInput = raw_input(MENU)
- # initiate the TorCtl connection if the test needs it
+ # initiate the stem connection if the test needs it
if userInput in ("1", "2", "4") and not conn:
conn = torTools.getConn()
conn.init()
diff --git a/src/util/torConfig.py b/src/util/torConfig.py
index c9ae6ef..0f6452d 100644
--- a/src/util/torConfig.py
+++ b/src/util/torConfig.py
@@ -471,8 +471,6 @@ def saveConf(destination = None, contents = None):
log.log(log.DEBUG, logMsg % ("SAVECONF", time.time() - startTime))
return # if successful then we're done
except:
- # example error:
- # TorCtl.TorCtl.ErrorReply: 551 Unable to write configuration to disk.
pass
# if the SAVECONF fails or this is a custom save then write contents directly
diff --git a/src/util/torTools.py b/src/util/torTools.py
index d2f1b0c..a5add1a 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -14,7 +14,7 @@ import Queue
import stem
import stem.control
-from TorCtl import TorCtl
+import stem.descriptor
from util import connections, enum, log, procTools, sysTools, uiTools
@@ -45,7 +45,7 @@ UNDEFINED = "<Undefined_ >"
UNKNOWN = "UNKNOWN" # value used by cached information if undefined
CONFIG = {"features.pathPrefix": "",
- "log.torCtlPortClosed": log.NOTICE,
+ "log.stemPortClosed": log.NOTICE,
"log.torPrefixPathInvalid": log.NOTICE,
"log.bsdJailFound": log.INFO,
"log.unknownBsdJailId": log.WARN}
@@ -265,22 +265,21 @@ def isTorRunning():
def getConn():
"""
Singleton constructor for a Controller. Be aware that this starts as being
- uninitialized, needing a TorCtl instance before it's fully functional.
+ uninitialized, needing a stem Controller before it's fully functional.
"""
global CONTROLLER
if CONTROLLER == None: CONTROLLER = Controller()
return CONTROLLER
-class Controller(TorCtl.PostEventListener):
+class Controller:
"""
- TorCtl wrapper providing convenience functions, listener functionality for
- tor's state, and the capability for controller connections to be restarted
- if closed.
+ Stem wrapper providing convenience functions (mostly from the days of using
+ TorCtl), listener functionality for tor's state, and the capability for
+ controller connections to be restarted if closed.
"""
def __init__(self):
- TorCtl.PostEventListener.__init__(self)
self.controller = None
self.connLock = threading.RLock()
self.statusListeners = [] # callback functions for tor's state changes
@@ -321,7 +320,7 @@ class Controller(TorCtl.PostEventListener):
def init(self, controller):
"""
- Uses the given TorCtl instance for future operations, notifying listeners
+ Uses the given stem instance for future operations, notifying listeners
about the change.
Arguments:
@@ -373,7 +372,7 @@ class Controller(TorCtl.PostEventListener):
def close(self):
"""
- Closes the current TorCtl instance and notifies listeners.
+ Closes the current stem instance and notifies listeners.
"""
self.connLock.acquire()
@@ -394,7 +393,7 @@ class Controller(TorCtl.PostEventListener):
def isAlive(self):
"""
- Returns True if this has been initialized with a working TorCtl instance,
+ Returns True if this has been initialized with a working stem instance,
False otherwise.
"""
@@ -1252,8 +1251,6 @@ class Controller(TorCtl.PostEventListener):
self._cachedParam = {}
except Exception, exc:
# new torrc parameters caused an error (tor's likely shut down)
- # BUG: this doesn't work - torrc errors still cause TorCtl to crash... :(
- # http://bugs.noreply.org/flyspray/index.php?do=details&id=1329
raisedException = IOError(str(exc))
else:
try:
@@ -1532,17 +1529,6 @@ class Controller(TorCtl.PostEventListener):
if len(attachedMatches) == 1:
return attachedMatches[0]
- # Highly unlikely, but still haven't found it. Last we'll use some
- # tricks from Mike's ConsensusTracker, excluding possiblities that
- # have...
- # - lost their Running flag
- # - list a bandwidth of 0
- # - have 'opt hibernating' set
- #
- # This involves constructing a TorCtl Router and checking its 'down'
- # flag (which is set by the three conditions above). This is the last
- # resort since it involves a couple GETINFO queries.
-
for entryPort, entryFingerprint in list(potentialMatches):
try:
nsEntry = self.controller.get_network_status(entryFingerprint)
@@ -1884,7 +1870,7 @@ class Controller(TorCtl.PostEventListener):
# gives a notice that the control port has closed
if eventType == State.CLOSED:
- log.log(CONFIG["log.torCtlPortClosed"], "Tor control port closed")
+ log.log(CONFIG["log.stemPortClosed"], "Tor control port closed")
for callback in self.statusListeners:
callback(self, eventType)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits