aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQingping Hou <dave2008713@gmail.com>2014-02-17 23:36:17 -0500
committerQingping Hou <dave2008713@gmail.com>2014-02-27 14:44:18 -0500
commit32d498be07ae9858d3f618fb52a7d32f9f0391d4 (patch)
tree9008c05ae887bc540df9459458dac2157657a511
parent735cb2dd6740bc7ecb5b3c5810fc6bf2e2be7597 (diff)
downloadchutney-32d498be07ae9858d3f618fb52a7d32f9f0391d4.tar
chutney-32d498be07ae9858d3f618fb52a7d32f9f0391d4.tar.gz
Print out help error message on binary not found
-rw-r--r--lib/chutney/TorNet.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index fed80c4..ec467a3 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -277,7 +277,17 @@ class LocalNodeBuilder(NodeBuilder):
'-a', addr]
print "Creating identity key %s for %s with %s"%(
idfile,self._env['nick']," ".join(cmdline))
- p = subprocess.Popen(cmdline, stdin=subprocess.PIPE)
+ try:
+ p = subprocess.Popen(cmdline, stdin=subprocess.PIPE)
+ except OSError as e:
+ # only catch file not found error
+ if errno.errorcode[e.errno] == 'ENOENT':
+ print ''.join(["Cannot find tor-gencert binary, use ",
+ "CHUTNEY_TOR_GENCERT environment variable to set the ",
+ "path or put the binary into $PATH."])
+ sys.exit(0)
+ else:
+ raise
p.communicate(passphrase+"\n")
assert p.returncode == 0 #XXXX BAD!
@@ -296,7 +306,17 @@ class LocalNodeBuilder(NodeBuilder):
"--dirserver",
"xyzzy 127.0.0.1:1 ffffffffffffffffffffffffffffffffffffffff",
"--datadirectory", datadir ]
- p = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
+ try:
+ p = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
+ except OSError as e:
+ # only catch file not found error
+ if errno.errorcode[e.errno] == 'ENOENT':
+ print ''.join(["Cannot find tor-gencert binary, use ",
+ "CHUTNEY_TOR_GENCERT environment variable to set the ",
+ "path or put the binary into $PATH."])
+ sys.exit(0)
+ else:
+ raise
stdout, stderr = p.communicate()
fingerprint = "".join(stdout.split()[1:])
assert re.match(r'^[A-F0-9]{40}$', fingerprint)
@@ -442,13 +462,24 @@ class LocalNodeController(NodeController):
if self.isRunning():
print "%s is already running"%self._env['nick']
return True
+ tor_path = self._env['tor']
torrc = self._getTorrcFname()
cmdline = [
- self._env['tor'],
+ tor_path,
"--quiet",
"-f", torrc,
]
- p = subprocess.Popen(cmdline)
+ try:
+ p = subprocess.Popen(cmdline)
+ except OSError as e:
+ # only catch file not found error
+ if errno.errorcode[e.errno] == 'ENOENT':
+ print ''.join(["Cannot find Tor binary, use CHUTNEY_TOR ",
+ "environment variable to set the path or put the binary ",
+ "into $PATH."])
+ sys.exit(0)
+ else:
+ raise
# XXXX this requires that RunAsDaemon is set.
p.wait()
if p.returncode != 0: