From: Brian Warner Date: Thu, 29 Mar 2007 21:32:28 +0000 (-0700) Subject: node creation: be willing to utilize a pre-existing (but empty) directory X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags?a=commitdiff_plain;h=3376c2b0a19656ba2da65781f7faf1cec4259093;p=tahoe-lafs%2Ftahoe-lafs.git node creation: be willing to utilize a pre-existing (but empty) directory --- diff --git a/src/allmydata/scripts/runner.py b/src/allmydata/scripts/runner.py index b2d79ff1..0da38bc1 100644 --- a/src/allmydata/scripts/runner.py +++ b/src/allmydata/scripts/runner.py @@ -118,7 +118,15 @@ def run(): def create_client(config): basedir = config['basedir'] - os.mkdir(basedir) + if os.path.exists(basedir): + if os.listdir(basedir): + print "The base directory already exists: %s" % basedir + print "To avoid clobbering anything, I am going to quit now" + print "Please use a different directory, or delete this one" + return -1 + # we're willing to use an empty directory + else: + os.mkdir(basedir) f = open(os.path.join(basedir, "client.tac"), "w") f.write(client_tac) f.close() @@ -127,7 +135,15 @@ def create_client(config): def create_queen(config): basedir = config['basedir'] - os.mkdir(basedir) + if os.path.exists(basedir): + if os.listdir(basedir): + print "The base directory already exists: %s" % basedir + print "To avoid clobbering anything, I am going to quit now" + print "Please use a different directory, or delete this one" + return -1 + # we're willing to use an empty directory + else: + os.mkdir(basedir) f = open(os.path.join(basedir, "queen.tac"), "w") f.write(queen_tac) f.close()