Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print path to config file in verdi status #3587

Merged
merged 2 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aiida/cmdline/commands/cmd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def profile_list():
@arguments.PROFILE(default=defaults.get_default_profile)
def profile_show(profile):
"""Show details for a profile."""

if profile is None:
echo.echo_critical('no profile to show')

echo.echo_info('Configuration for: {}'.format(profile.name))
echo.echo_info('Profile: {}'.format(profile.name))
data = sorted([(k.lower(), v) for k, v in profile.dictionary.items()])
echo.echo(tabulate.tabulate(data))

Expand Down
6 changes: 5 additions & 1 deletion aiida/cmdline/commands/cmd_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ def verdi_status():
from aiida.common.utils import Capturing
from aiida.manage.external.rmq import get_rmq_url
from aiida.manage.manager import get_manager
from aiida.manage.configuration.settings import AIIDA_CONFIG_FOLDER

exit_code = ExitCode.SUCCESS

# path to configuration file
print_status(ServiceStatus.UP, 'config dir', AIIDA_CONFIG_FOLDER)

manager = get_manager()
profile = manager.get_profile()

# getting the profile
try:
profile = manager.get_profile()
print_status(ServiceStatus.UP, 'profile', 'On profile {}'.format(profile.name))
Expand Down
13 changes: 10 additions & 3 deletions aiida/manage/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

__all__ = (
config.__all__ + options.__all__ + profile.__all__ +
('get_config', 'get_config_option', 'load_profile', 'reset_config')
('get_config', 'get_config_option', 'get_config_path', 'load_profile', 'reset_config')
)


Expand Down Expand Up @@ -66,6 +66,14 @@ def load_profile(profile=None):
return PROFILE


def get_config_path():
"""Returns path to .aiida configuration directory."""
import os
from .settings import AIIDA_CONFIG_FOLDER, DEFAULT_CONFIG_FILE_NAME

return os.path.join(AIIDA_CONFIG_FOLDER, DEFAULT_CONFIG_FILE_NAME)


def load_config(create=False):
"""Instantiate Config object representing an AiiDA configuration file.

Expand All @@ -82,9 +90,8 @@ def load_config(create=False):
import os
from aiida.common import exceptions
from .config import Config
from .settings import AIIDA_CONFIG_FOLDER, DEFAULT_CONFIG_FILE_NAME

filepath = os.path.join(AIIDA_CONFIG_FOLDER, DEFAULT_CONFIG_FILE_NAME)
filepath = get_config_path()

if not os.path.isfile(filepath) and not create:
raise exceptions.MissingConfigurationError('configuration file {} does not exist'.format(filepath))
Expand Down
1 change: 1 addition & 0 deletions tests/cmdline/commands/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_status_1(self):
options = []
result = self.cli_runner.invoke(cmd_status.verdi_status, options)
self.assertIsInstance(result.exception, SystemExit)
self.assertIn('config', result.output)
self.assertIn('profile', result.output)
self.assertIn('postgres', result.output)
self.assertIn('rabbitmq', result.output)
Expand Down