From: Brian Warner Date: Thu, 24 May 2007 18:20:39 +0000 (-0700) Subject: runner.py: spoke too soon. Really fix #51 this time. X-Git-Tag: allmydata-tahoe-0.3.0~52 X-Git-Url: https://git.rkrishnan.org/uri/URI:DIR2:%5B%5E?a=commitdiff_plain;h=4c7c5df41e0236b27b071c3b6d861d976097001e;p=tahoe-lafs%2Ftahoe-lafs.git runner.py: spoke too soon. Really fix #51 this time. --- diff --git a/src/allmydata/scripts/runner.py b/src/allmydata/scripts/runner.py index 4d0d14ed..6b7af830 100644 --- a/src/allmydata/scripts/runner.py +++ b/src/allmydata/scripts/runner.py @@ -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(" 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(" 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(" 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,])