Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
janvanmansum committed Nov 28, 2023
1 parent 8bb1030 commit 47e07a4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ def get_dataverse_version(dataverse_application_path):
return line.split('"')[1]

Check warning on line 30 in src/datastation/common/version_info.py

View check run for this annotation

Codecov / codecov/patch

src/datastation/common/version_info.py#L28-L30

Added lines #L28 - L30 were not covered by tests


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:
return line.split('"')[1]

Check warning on line 37 in src/datastation/common/version_info.py

View check run for this annotation

Codecov / codecov/patch

src/datastation/common/version_info.py#L34-L37

Added lines #L34 - L37 were not covered by tests


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',

Check warning on line 41 in src/datastation/common/version_info.py

View check run for this annotation

Codecov / codecov/patch

src/datastation/common/version_info.py#L41

Added line #L41 was not covered by tests
'glassfish-api.jar'), 'r') as f:
for line in f:
if 'Implementation-Version' in line:
return line.split(' ')[1].strip()
return line.split(' ')[1].strip()

Check warning on line 45 in src/datastation/common/version_info.py

View check run for this annotation

Codecov / codecov/patch

src/datastation/common/version_info.py#L43-L45

Added lines #L43 - L45 were not covered by tests
24 changes: 18 additions & 6 deletions src/datastation/datastation_module_versions.py
Original file line number Diff line number Diff line change
@@ -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__':
Expand Down
6 changes: 6 additions & 0 deletions src/datastation/example-dans-datastation-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions src/tests/test_module_info.py
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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 == {}

0 comments on commit 47e07a4

Please sign in to comment.