mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-30 17:56:58 +00:00
startstop_node.py: refactor find_twistd() out so it is only run when you need to start a node
This commit is contained in:
parent
f22801aa33
commit
d8a878da86
@ -31,39 +31,31 @@ def testtwistd(loc):
|
|||||||
except:
|
except:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
twistd = None
|
def find_twistd():
|
||||||
if not twistd:
|
|
||||||
for maybetwistd in which("twistd"):
|
for maybetwistd in which("twistd"):
|
||||||
ret = testtwistd(maybetwistd)
|
ret = testtwistd(maybetwistd)
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
twistd = maybetwistd
|
return maybetwistd
|
||||||
break
|
|
||||||
|
|
||||||
if not twistd:
|
|
||||||
for maybetwistd in which("twistd.py"):
|
for maybetwistd in which("twistd.py"):
|
||||||
ret = testtwistd(maybetwistd)
|
ret = testtwistd(maybetwistd)
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
twistd = maybetwistd
|
return maybetwistd
|
||||||
break
|
|
||||||
|
|
||||||
if not twistd:
|
|
||||||
maybetwistd = os.path.join(sys.prefix, 'Scripts', 'twistd')
|
maybetwistd = os.path.join(sys.prefix, 'Scripts', 'twistd')
|
||||||
ret = testtwistd(maybetwistd)
|
ret = testtwistd(maybetwistd)
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
twistd = maybetwistd
|
return maybetwistd
|
||||||
|
|
||||||
if not twistd:
|
|
||||||
maybetwistd = os.path.join(sys.prefix, 'Scripts', 'twistd.py')
|
maybetwistd = os.path.join(sys.prefix, 'Scripts', 'twistd.py')
|
||||||
ret = testtwistd(maybetwistd)
|
ret = testtwistd(maybetwistd)
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
twistd = maybetwistd
|
return maybetwistd
|
||||||
|
|
||||||
if not twistd:
|
|
||||||
print "Can't find twistd (it comes with Twisted). Aborting."
|
print "Can't find twistd (it comes with Twisted). Aborting."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def do_start(basedir, config, out=sys.stdout, err=sys.stderr):
|
def do_start(basedir, config, out=sys.stdout, err=sys.stderr):
|
||||||
print >>out, "STARTING", basedir
|
print >>out, "STARTING", basedir
|
||||||
if os.path.exists(os.path.join(basedir, "client.tac")):
|
if os.path.exists(os.path.join(basedir, "client.tac")):
|
||||||
@ -77,6 +69,7 @@ def do_start(basedir, config, out=sys.stdout, err=sys.stderr):
|
|||||||
if not os.path.isdir(basedir):
|
if not os.path.isdir(basedir):
|
||||||
print >>err, " in fact, it doesn't look like a directory at all!"
|
print >>err, " in fact, it doesn't look like a directory at all!"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
twistd = find_twistd()
|
||||||
rc = subprocess.call(["python", twistd, "-y", tac,], cwd=basedir)
|
rc = subprocess.call(["python", twistd, "-y", tac,], cwd=basedir)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
print >>out, "%s node probably started" % type
|
print >>out, "%s node probably started" % type
|
||||||
|
Loading…
Reference in New Issue
Block a user