Merge "Specify the default root dir in opts."

This commit is contained in:
Jenkins 2013-08-13 04:25:57 +00:00 committed by Gerrit Code Review
commit 852440a65c
2 changed files with 12 additions and 11 deletions

View File

@ -29,7 +29,6 @@ sys.path.insert(0, os.path.abspath(os.getcwd()))
from anvil import actions
from anvil import colorizer
from anvil import distro
from anvil import env
from anvil import exceptions as excp
from anvil import log as logging
from anvil import opts
@ -71,15 +70,8 @@ def run(args):
if not sh.isfile(persona_fn):
raise excp.OptionException("Invalid persona file %r specified!" % (persona_fn))
# Determine + setup the root directory...
# If not provided attempt to locate it via the environment control files
args_root_dir = args.pop("dir")
root_dir = env.get_key('INSTALL_ROOT')
if not root_dir:
root_dir = args_root_dir
if not root_dir:
root_dir = sh.joinpths(sh.gethomedir(), 'openstack')
root_dir = sh.abspth(root_dir)
# Determine the root directory...
root_dir = sh.abspth(args.pop("dir"))
(repeat_string, line_max_len) = utils.welcome()
print(pprint.center_text("Action Runner", repeat_string, line_max_len))

View File

@ -25,6 +25,7 @@ from optparse import OptionParser
from optparse import OptionValueError
from anvil import actions
from anvil import env
from anvil import settings
from anvil import shell as sh
from anvil import utils
@ -100,6 +101,13 @@ class SmithyHelpFormatter(IndentedHelpFormatter):
return buf.getvalue()
def _get_default_dir():
root_dir = env.get_key('INSTALL_ROOT')
if root_dir:
return root_dir
return sh.joinpths(sh.gethomedir(), 'openstack')
def parse(previous_settings=None):
version_str = "%s v%s" % ('anvil', version.version_string())
@ -167,7 +175,8 @@ def parse(previous_settings=None):
type="string",
dest="dir",
metavar="DIR",
help=("empty root DIR or DIR with existing components"))
default=_get_default_dir(),
help=("empty root DIR or DIR with existing components (default: %default)"))
parser.add_option_group(base_group)
suffixes = ("Known suffixes 'K' (kilobyte, 1024),"