diff --git a/anvil/__main__.py b/anvil/__main__.py index 41b7097b..e8990a94 100644 --- a/anvil/__main__.py +++ b/anvil/__main__.py @@ -28,7 +28,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 @@ -69,15 +68,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)) diff --git a/anvil/opts.py b/anvil/opts.py index 65b3a108..28948694 100644 --- a/anvil/opts.py +++ b/anvil/opts.py @@ -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),"