diff --git a/src/datastation/common/module_info.py b/src/datastation/common/version_info.py similarity index 85% rename from src/datastation/common/module_info.py rename to src/datastation/common/version_info.py index dd4543c..3b02d15 100644 --- a/src/datastation/common/module_info.py +++ b/src/datastation/common/version_info.py @@ -30,7 +30,7 @@ def get_dataverse_version(dataverse_application_path): return line.split('"')[1] -def get_build_number(dataverse_application_path): +def get_dataverse_build_number(dataverse_application_path): with open(os.path.join(dataverse_application_path, 'WEB-INF', 'classes', 'BuildNumber.properties'), 'r') as f: for line in f: if 'build.number' in line: @@ -38,7 +38,8 @@ def get_build_number(dataverse_application_path): def get_payara_version(payara_application_path): - with open(os.path.join(payara_application_path, 'glassfish', 'modules', 'org', 'glassfish', 'main', 'glassfish-api.jar'), 'r') as f: + with open(os.path.join(payara_application_path, 'glassfish', 'modules', 'org', 'glassfish', 'main', + 'glassfish-api.jar'), 'r') as f: for line in f: if 'Implementation-Version' in line: - return line.split(' ')[1].strip() \ No newline at end of file + return line.split(' ')[1].strip() diff --git a/src/datastation/datastation_module_versions.py b/src/datastation/datastation_module_versions.py index c05dc3b..b1d236f 100644 --- a/src/datastation/datastation_module_versions.py +++ b/src/datastation/datastation_module_versions.py @@ -1,13 +1,25 @@ -import os +from rich import Console +from rich.table import Table -import rich - -from datastation.common.module_info import get_rpm_versions +from datastation.common.config import init +from datastation.common.version_info import get_rpm_versions, get_dataverse_version def main(): - rpm_modules = get_rpm_versions('dans.knaw.nl-') - rich.print(rpm_modules) + config = init() + components = get_rpm_versions(config['version_info']['dans_rpm_module_prefix']) + dataverse_version = get_dataverse_version(config['version_info']['dataverse_application_path']) + components['dataverse'] = dataverse_version + payara_version = get_dataverse_version(config['version_info']['payara_install_path']) + components['payara'] = payara_version + table = Table(title="Data Station Component Versions") + table.add_column("Component") + table.add_column("Version") + for component in components: + table.add_row(component, components[component]) + console = Console() + console.print(table) + if __name__ == '__main__': diff --git a/src/datastation/example-dans-datastation-tools.yml b/src/datastation/example-dans-datastation-tools.yml index 7c5502d..43e04a8 100644 --- a/src/datastation/example-dans-datastation-tools.yml +++ b/src/datastation/example-dans-datastation-tools.yml @@ -41,6 +41,12 @@ reingest_files: manage_deposit: service_baseurl: 'http://localhost:20355' +version_info: + dans_rpm_module_prefix: 'dans.knaw.nl-' + dataverse_application_path: '/var/lib/payara5/glassfish/domains/domain1/applications/dataverse/' + payara_install_path: '/usr/local/payara5' + + logging: version: 1 root: diff --git a/src/tests/test_module_info.py b/src/tests/test_module_info.py index 05a6ffa..ad217c1 100644 --- a/src/tests/test_module_info.py +++ b/src/tests/test_module_info.py @@ -1,10 +1,10 @@ from unittest.mock import patch -from datastation.common.module_info import get_rpm_versions +from datastation.common.version_info import get_rpm_versions -def test_only_modules_with_matching_prefix_found(): - with patch('datastation.common.module_info.rpm_qa') as mock_qa: +def test_some_modules_with_matching_prefix_found(): + with patch('datastation.common.version_info.rpm_qa') as mock_qa: mock_qa.return_value = ['dans.knaw.nl-dd-vault-metadata-2.2.0-1.noarch', 'dans.knaw.nl-dans-schema-0.10.0-1.noarch', 'python3-rpm-generators-5-8.el8.noarch', @@ -18,8 +18,8 @@ def test_only_modules_with_matching_prefix_found(): } -def test_no_modules_found(): - with patch('datastation.common.module_info.rpm_qa') as mock_qa: +def test_no_matching_modules_found(): + with patch('datastation.common.version_info.rpm_qa') as mock_qa: mock_qa.return_value = ['python3-rpm-generators-5-8.el8.noarch'] versions = get_rpm_versions('dans.knaw.nl-') assert versions == {}