[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Debug: add some debug output, and move other outputs to debug



commit 624da7316d5a90e5dca3da69162365eb0171c627
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Tue Oct 23 15:22:45 2018 +1000

    Debug: add some debug output, and move other outputs to debug
---
 chutney               |  2 +-
 lib/chutney/TorNet.py | 32 +++++++++++++++++---------------
 tools/test-network.sh |  2 +-
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/chutney b/chutney
index f231e66..7c7e1df 100755
--- a/chutney
+++ b/chutney
@@ -51,5 +51,5 @@ then
     exit 1
 fi
 
-printf "Using %s\n" "$("${PYTHON}" --version 2>&1)"
+printf "\nLaunching chutney using %s\n" "$("${PYTHON}" --version 2>&1)"
 "${PYTHON}" -m chutney.TorNet "${@}"
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index e4465c9..8c6cb57 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -112,6 +112,7 @@ def run_tor(cmdline):
                                             stderr=subprocess.STDOUT,
                                             universal_newlines=True,
                                             bufsize=-1)
+        debug(stdouterr)
     except OSError as e:
         # only catch file not found error
         if e.errno == errno.ENOENT:
@@ -166,6 +167,7 @@ def run_tor_gencert(cmdline, passphrase):
                         tor_name="tor-gencert",
                         stdin=subprocess.PIPE)
     (stdouterr, empty_stderr) = p.communicate(passphrase + "\n")
+    debug(stdouterr)
     assert p.returncode == 0  # XXXX BAD!
     assert empty_stderr is None
     return stdouterr
@@ -480,9 +482,11 @@ class LocalNodeBuilder(NodeBuilder):
             '-m', str(lifetime),
             '-a', addr,
             ]
-        print("Creating identity key %s for %s with %s" % (
-            idfile, self._env['nick'], " ".join(cmdline)))
-        outerr = run_tor_gencert(cmdline, passphrase)
+        print("Creating identity key for {} with {}"
+              .format(self._env['nick'], cmdline[0]))
+        debug("Identity key path '{}', command {}"
+              .format(idfile, " ".join(cmdline)))
+        run_tor_gencert(cmdline, passphrase)
 
     def _genRouterKey(self):
         """Generate an identity key for this router, unless we already have,
@@ -664,6 +668,7 @@ class LocalNodeController(NodeController):
         if self.waitOnLaunch():
             # this requires that RunAsDaemon is set
             (stdouterr, empty_stderr) = p.communicate()
+            debug(stdouterr)
             assert empty_stderr is None
         else:
             # this does not require RunAsDaemon to be set, but is slower.
@@ -707,8 +712,8 @@ class LocalNodeController(NodeController):
     def cleanup_lockfile(self):
         lf = self._env['lockfile']
         if not self.isRunning() and os.path.exists(lf):
-            print('Removing stale lock file for {0} ...'.format(
-                self._env['nick']))
+            debug('Removing stale lock file for {0} ...'
+                  .format(self._env['nick']))
             os.remove(lf)
 
     def waitOnLaunch(self):
@@ -926,8 +931,8 @@ class TorEnviron(chutney.Templating.Environ):
             return "#ServerDNSResolvConfFile using tor's compile-time default"
         elif my['dns_conf'] is None:
             # if there is no DNS conf file set
-            print("CHUTNEY_DNS_CONF not specified, using '%s'."
-                  % (TorEnviron.DEFAULT_DNS_RESOLV_CONF))
+            debug("CHUTNEY_DNS_CONF not specified, using '{}'."
+                  .format(TorEnviron.DEFAULT_DNS_RESOLV_CONF))
             dns_conf = TorEnviron.DEFAULT_DNS_RESOLV_CONF
         else:
             dns_conf = my['dns_conf']
@@ -937,8 +942,8 @@ class TorEnviron(chutney.Templating.Environ):
         # (os.path.exists returns False for broken symbolic links)
         if not os.path.exists(dns_conf):
             # Issue a warning so the user notices
-            print("CHUTNEY_DNS_CONF '%s' does not exist, using '%s'."
-                  % (dns_conf, TorEnviron.OFFLINE_DNS_RESOLV_CONF))
+            print("CHUTNEY_DNS_CONF '{}' does not exist, using '{}'."
+                  .format(dns_conf, TorEnviron.OFFLINE_DNS_RESOLV_CONF))
             dns_conf = TorEnviron.OFFLINE_DNS_RESOLV_CONF
         return "ServerDNSResolvConfFile %s" % (dns_conf)
 
@@ -1055,12 +1060,9 @@ class Network(object):
         self.start()
 
     def start(self):
-        if self._dfltEnv['poll_launch_time'] is not None:
-            # format polling correctly - avoid printing a newline
-            sys.stdout.write("Starting nodes")
-            sys.stdout.flush()
-        else:
-            print("Starting nodes")
+        # format polling correctly - avoid printing a newline
+        sys.stdout.write("Starting nodes")
+        sys.stdout.flush()
         rv = all([n.getController().start() for n in self._nodes])
         # now print a newline unconditionally - this stops poll()ing
         # output from being squashed together, at the cost of a blank
diff --git a/tools/test-network.sh b/tools/test-network.sh
index 603ff9c..4509fa3 100755
--- a/tools/test-network.sh
+++ b/tools/test-network.sh
@@ -224,7 +224,7 @@ if [ -d "$TOR_DIR" ]; then
         $ECHO "$myname: \$TOR_DIR is a Tor 0.3.4 or earlier build directory"
         TOR_APP_DIR="$TOR_DIR/src/or"
     else
-        $ECHO "$myname: \$TOR_DIR has no src/app or src/or, chutney will use \$CHUTNEY_TOR and \$CHUTNEY_TOR_GENCERT as tor binary paths, or search \$PATH for tor binary names"
+        $ECHO "$myname: \$TOR_DIR has no src/app or src/or, looking elsewhere"
         unset TOR_DIR
     fi
 fi



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits