Add check on root dir so that we can ensure its useable ahead of time

This commit is contained in:
Joshua Harlow 2012-04-11 12:47:29 -07:00
parent eff471adea
commit 1793e79880
2 changed files with 7 additions and 0 deletions

View File

@ -200,6 +200,10 @@ def abspth(path):
return os.path.abspath(path)
def isuseable(path, options=os.W_OK|os.R_OK|os.X_OK):
return os.access(path, options)
def shellquote(text):
# TODO since there doesn't seem to be a standard lib that actually works use this way...
do_adjust = False

3
stack
View File

@ -121,6 +121,9 @@ def run(args):
root_dir = sh.joinpths(sh.gethomedir(), 'openstack')
root_dir = sh.abspth(root_dir)
setup_root(root_dir)
if not sh.isuseable(root_dir):
print(utils.color_text("Unreadable/writeable/executable root directory %r provided!" % (root_dir), "red"))
return False
persona_fn = args.pop('persona_fn')
if not persona_fn or not sh.isfile(persona_fn):