commit 000d5d9efda100758b2e8f703a13ebd76bcb457a Author: Damian Johnson atagar@torproject.org Date: Sat Jul 9 18:43:57 2011 -0700
Giving better error output when tor startup fails
The error out was pointless (any startup failure reported as being unable to connect to the control port) so giving the user the command to manually start tor. I should try to capture the logged err msg but this is gonna be a little tricky... --- src/cli/controller.py | 12 ++++++------ src/cli/wizard.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/cli/controller.py b/src/cli/controller.py index d4ee3e3..a04bf99 100644 --- a/src/cli/controller.py +++ b/src/cli/controller.py @@ -462,20 +462,20 @@ class TorManager: Starts a managed instance of tor, raising an IOError if unsuccessful. """
- os.system("tor --quiet -f %s&" % self.getTorrcPath()) + torrcLoc = self.getTorrcPath() + os.system("tor --quiet -f %s&" % torrcLoc) startTime = time.time()
# attempts to connect for five seconds (tor might or might not be # immediately available) - torctlConn, authType, authValue, raisedExc = None, None, None, None + torctlConn, authType, authValue = None, None, None while not torctlConn and time.time() - startTime < 5: try: torctlConn, authType, authValue = TorCtl.preauth_connect(controlPort = int(CONFIG["wizard.default"]["Control"])) - except IOError, exc: - raisedExc = exc - time.sleep(0.5) + except IOError, exc: time.sleep(0.5)
- if not torctlConn: raise raisedExc + if not torctlConn: + raise IOError("try running "tor -f %s" for error output" % torrcLoc)
if authType == TorCtl.AUTH_TYPE.COOKIE: torctlConn.authenticate(authValue) diff --git a/src/cli/wizard.py b/src/cli/wizard.py index 8aa1a23..6d2e623 100644 --- a/src/cli/wizard.py +++ b/src/cli/wizard.py @@ -304,7 +304,7 @@ def showWizard(): if manager.isManaged(conn): conn.reset() else: manager.startManagedInstance() except IOError, exc: - log.log(log.WARN, "Unable to start tor: %s" % exc) + log.log(log.WARN, "Unable to start tor, %s" % exc)
break elif confirmationSelection == CANCEL: break @@ -512,7 +512,7 @@ def getTorrc(relayType, config): # exit notice will be in our data directory dataDir = cli.controller.getController().getDataDirectory() templateOptions["NOTICE_PATH"] = dataDir + "exit-notice.html" - templateOptions["LOG_ENTRY"] = "notice file %stor-log" % dataDir + templateOptions["LOG_ENTRY"] = "notice file %stor_log" % dataDir
policyCategories = [] if not config[Options.POLICY].getValue():
tor-commits@lists.torproject.org