]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
'tahoe start': allow this to start arbitrary .tac file -bearing directories (like...
authorBrian Warner <warner@lothar.com>
Mon, 18 Feb 2008 07:28:17 +0000 (00:28 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 18 Feb 2008 07:28:17 +0000 (00:28 -0700)
src/allmydata/scripts/startstop_node.py
src/allmydata/test/test_runner.py

index aa7bc0c3e084770e9b844b9249a77875c05820c1..c79bad1146d8f967d9c42d13845cf9df98f24698 100644 (file)
@@ -35,23 +35,22 @@ class RunOptions(usage.Options):
 
 def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr):
     print >>out, "STARTING", basedir
-    if os.path.exists(os.path.join(basedir, "client.tac")):
-        tac = "client.tac"
-        type = "client"
-    elif os.path.exists(os.path.join(basedir, "tahoe-client.tac")):
-        tac = "tahoe-client.tac"
-        type = "client"
-    elif os.path.exists(os.path.join(basedir, "introducer.tac")):
-        tac = "introducer.tac"
-        type = "introducer"
-    elif os.path.exists(os.path.join(basedir, "tahoe-introducer.tac")):
-        tac = "tahoe-introducer.tac"
-        type = "introducer"
+    if not os.path.isdir(basedir):
+        print >>err, "%s does not look like a directory at all" % basedir
+        return 1
+    for fn in os.listdir(basedir):
+        if fn.endswith(".tac"):
+            tac = fn
+            break
     else:
-        print >>err, "%s does not look like a node directory" % basedir
-        if not os.path.isdir(basedir):
-            print >>err, " in fact, it doesn't look like a directory at all!"
+        print >>err, "%s does not look like a node directory (no .tac file)" % basedir
         return 1
+    if "client" in tac:
+        nodetype = "client"
+    elif "introducer" in tac:
+        nodetype = "introducer"
+    else:
+        nodetype = "unknown (%s)" % tac
 
     cmd = find_exe.find_exe('twistd')
     if not cmd:
@@ -59,7 +58,9 @@ def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr):
         sys.exit(1)
 
     fileutil.make_dirs(os.path.join(basedir, "logs"))
-    cmd.extend(["-y", tac, "--logfile", os.path.join("logs", "twistd.log")])
+    cmd.extend(["-y", tac])
+    if nodetype in ("client", "introducer"):
+        cmd.extend(["--logfile", os.path.join("logs", "twistd.log")])
     if profile:
         cmd.extend(["--profile=profiling_results.prof", "--savestats",])
     curdir = os.getcwd()
@@ -69,10 +70,10 @@ def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr):
     finally:
         os.chdir(curdir)
     if rc == 0:
-        print >>out, "%s node probably started" % type
+        print >>out, "%s node probably started" % nodetype
         return 0
     else:
-        print >>err, "%s node probably not started" % type
+        print >>err, "%s node probably not started" % nodetype
         return 1
 
 def do_stop(basedir, out=sys.stdout, err=sys.stderr):
index aa71c17921c7b21a5b81d4c289db28b6ac9c5443..5bd90ddb8987363a642339bf76b07e2f10247db4 100644 (file)
@@ -215,8 +215,7 @@ class RunNode(unittest.TestCase, testutil.PollMixin):
         out,err = StringIO(), StringIO()
         rc = runner.runner(argv, stdout=out, stderr=err)
         self.failUnlessEqual(rc, 1)
-        self.failUnless("does not look like a node directory" in err.getvalue())
-        self.failUnless("doesn't look like a directory at all"
-                        in err.getvalue())
+        self.failUnless("does not look like a directory at all"
+                        in err.getvalue(), err.getvalue())