]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
startstop_node.py: find twistd in our supportlib if we had to build Twisted as a...
authorBrian Warner <warner@allmydata.com>
Fri, 12 Sep 2008 02:51:38 +0000 (19:51 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 12 Sep 2008 02:51:38 +0000 (19:51 -0700)
src/allmydata/scripts/startstop_node.py

index 81c6f7649028d69ddbcf1822137516d0a6feb90c..5863efb6d9918f0974a2004fd87fd79f74207a68 100644 (file)
@@ -53,6 +53,21 @@ def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr):
         nodetype = "unknown (%s)" % tac
 
     cmd = find_exe.find_exe('twistd')
+    if not cmd:
+        # If 'twistd' wasn't on $PATH, maybe we're running from source and
+        # Twisted was built as one of our dependencies. If so, we're at
+        # BASEDIR/src/allmydata/scripts/startstop_node.py, and it's at
+        # BASEDIR/support/bin/twistd
+        up = os.path.dirname
+        TAHOEDIR = up(up(up(up(os.path.abspath(__file__)))))
+        bindir = os.path.join(TAHOEDIR, "support/bin")
+        maybe = os.path.join(bindir, "twistd")
+        if os.path.exists(maybe):
+            cmd = [maybe]
+            oldpath = os.environ.get("PATH", "").split(os.pathsep)
+            os.environ["PATH"] = os.pathsep.join(oldpath + [bindir])
+            # sys.path and $PYTHONPATH are taken care of by the extra code in
+            # 'setup.py trial'
     if not cmd:
         print "Can't find twistd (it comes with Twisted).  Aborting."
         sys.exit(1)