]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
runner.py: spoke too soon. Really fix #51 this time.
authorBrian Warner <warner@allmydata.com>
Thu, 24 May 2007 18:20:39 +0000 (11:20 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 24 May 2007 18:20:39 +0000 (11:20 -0700)
src/allmydata/scripts/runner.py

index 4d0d14ed89d49dbaeb40ecd9cde1c2521b5792b7..6b7af83055516281483e62a63836e53fd763aee6 100644 (file)
@@ -41,23 +41,29 @@ if not twistd:
 if not twistd:
     print "Can't find twistd (it comes with Twisted).  Aborting."
     sys.exit(1)
-    
-class StartOptions(usage.Options):
+
+class BasedirMixin:
+    def postOptions(self):
+        if self['basedir'] is None:
+            raise usage.UsageError("<basedir> parameter is required")
+        self['basedir'] = os.path.abspath(os.path.expanduser(self['basedir']))
+
+class StartOptions(BasedirMixin, usage.Options):
     optParameters = [
         ["basedir", "C", ".", "which directory to start the node in"],
         ]
 
-class StopOptions(usage.Options):
+class StopOptions(BasedirMixin, usage.Options):
     optParameters = [
         ["basedir", "C", ".", "which directory to stop the node in"],
         ]
 
-class RestartOptions(usage.Options):
+class RestartOptions(BasedirMixin, usage.Options):
     optParameters = [
         ["basedir", "C", ".", "which directory to restart the node in"],
         ]
 
-class CreateClientOptions(usage.Options):
+class CreateClientOptions(BasedirMixin, usage.Options):
     optParameters = [
         ["basedir", "C", None, "which directory to create the client in"],
         ]
@@ -71,12 +77,7 @@ class CreateClientOptions(usage.Options):
         if len(args) > 1:
             raise usage.UsageError("I wasn't expecting so many arguments")
 
-    def postOptions(self):
-        if self['basedir'] is None:
-            raise usage.UsageError("<basedir> parameter is required")
-        self['basedir'] = os.path.abspath(os.path.expanduser(self['basedir']))
-
-class CreateIntroducerOptions(usage.Options):
+class CreateIntroducerOptions(BasedirMixin, usage.Options):
     optParameters = [
         ["basedir", "C", None, "which directory to create the introducer in"],
         ]
@@ -90,11 +91,6 @@ class CreateIntroducerOptions(usage.Options):
         if len(args) > 1:
             raise usage.UsageError("I wasn't expecting so many arguments")
 
-    def postOptions(self):
-        if self['basedir'] is None:
-            raise usage.UsageError("<basedir> parameter is required")
-        self['basedir'] = os.path.abspath(self['basedir'])
-
 client_tac = """
 # -*- python -*-
 
@@ -212,6 +208,8 @@ def start(config):
         type = "introducer"
     else:
         print "%s does not look like a node directory" % basedir
+        if not os.path.isdir(basedir):
+            print " in fact, it doesn't look like a directory at all!"
         sys.exit(1)
     os.chdir(basedir)
     rc = subprocess.call(["python", twistd, "-y", tac,])