diff --git a/ceda_elasticsearch_tools/__init__.py b/ceda_elasticsearch_tools/__init__.py index 724e083..8b1ac42 100644 --- a/ceda_elasticsearch_tools/__init__.py +++ b/ceda_elasticsearch_tools/__init__.py @@ -1,4 +1,7 @@ from .elasticsearch.ceda_elasticsearch_client import CEDAElasticsearchClient from .index_tools.base import IndexUpdaterBase -from .index_tools.ceda_client import BulkClient \ No newline at end of file +from .index_tools.ceda_client import BulkClient + +from importlib.metadata import version +__version__ = version \ No newline at end of file diff --git a/ceda_elasticsearch_tools/cmdline/__init__.py b/ceda_elasticsearch_tools/cmdline/__init__.py index 7dbd61d..e69de29 100644 --- a/ceda_elasticsearch_tools/cmdline/__init__.py +++ b/ceda_elasticsearch_tools/cmdline/__init__.py @@ -1,2 +0,0 @@ -import pkg_resources -__version__ = pkg_resources.require("ceda_elasticsearch_tools")[0].version \ No newline at end of file diff --git a/ceda_elasticsearch_tools/cmdline/ceda_eo/coverage_test.py b/ceda_elasticsearch_tools/cmdline/ceda_eo/coverage_test.py index d3c2fe5..3698b61 100644 --- a/ceda_elasticsearch_tools/cmdline/ceda_eo/coverage_test.py +++ b/ceda_elasticsearch_tools/cmdline/ceda_eo/coverage_test.py @@ -15,13 +15,11 @@ from docopt import docopt import simplejson as json -from ceda_elasticsearch_tools.cmdline import __version__ +from ceda_elasticsearch_tools import __version__ import os import re from ceda_elasticsearch_tools.core.updater import ElasticsearchUpdater, ElasticsearchQuery -from ceda_elasticsearch_tools.core import util - - +from ceda_elasticsearch_tools.core import utils def main(): base = os.path.dirname(__file__) @@ -71,7 +69,7 @@ def main(): print(f"Group: {group} Total files: {len(file_list)}" f" Files in: {len(results['True'])} Files out: {len(results['False'])}" - f" Coverage: {util.percent(len(file_list),len(results['True']))}") + f" Coverage: {utils.percent(len(file_list),len(results['True']))}") diff --git a/ceda_elasticsearch_tools/cmdline/fbs_missing_files.py b/ceda_elasticsearch_tools/cmdline/fbs_missing_files.py index 8236ecb..159e134 100644 --- a/ceda_elasticsearch_tools/cmdline/fbs_missing_files.py +++ b/ceda_elasticsearch_tools/cmdline/fbs_missing_files.py @@ -35,7 +35,7 @@ import os from ceda_elasticsearch_tools.core import utils import subprocess -from ceda_elasticsearch_tools.cmdline import __version__ +from ceda_elasticsearch_tools import __version__ from time import sleep from tqdm import tqdm diff --git a/ceda_elasticsearch_tools/cmdline/nla_sync_es.py b/ceda_elasticsearch_tools/cmdline/nla_sync_es.py index bfa3eaa..db76344 100644 --- a/ceda_elasticsearch_tools/cmdline/nla_sync_es.py +++ b/ceda_elasticsearch_tools/cmdline/nla_sync_es.py @@ -27,7 +27,7 @@ from docopt import docopt import requests -import pkg_resources +from ceda_elasticsearch_tools import __version__ from time import sleep import itertools, sys from multiprocessing import Process @@ -122,7 +122,7 @@ def main(): """ # Get command line arguments - args = docopt(__doc__, version=pkg_resources.require("ceda_elasticsearch_tools")[0].version) + args = docopt(__doc__, version=__version__) if not args["--host"]: host = "jasmin-es1.ceda.ac.uk" diff --git a/ceda_elasticsearch_tools/cmdline/secondary_scripts/md5.py b/ceda_elasticsearch_tools/cmdline/secondary_scripts/md5.py index c88e54d..27d69e0 100644 --- a/ceda_elasticsearch_tools/cmdline/secondary_scripts/md5.py +++ b/ceda_elasticsearch_tools/cmdline/secondary_scripts/md5.py @@ -32,7 +32,7 @@ from ceda_elasticsearch_tools.core import updater from datetime import datetime import os, logging -from ceda_elasticsearch_tools.cmdline import __version__ +from ceda_elasticsearch_tools import __version__ import hashlib import simplejson as json diff --git a/ceda_elasticsearch_tools/cmdline/secondary_scripts/spot_checker.py b/ceda_elasticsearch_tools/cmdline/secondary_scripts/spot_checker.py index dd2f367..9ac132f 100644 --- a/ceda_elasticsearch_tools/cmdline/secondary_scripts/spot_checker.py +++ b/ceda_elasticsearch_tools/cmdline/secondary_scripts/spot_checker.py @@ -27,7 +27,7 @@ import os import simplejson as json from elasticsearch import Elasticsearch -from ceda_elasticsearch_tools.cmdline import __version__ +from ceda_elasticsearch_tools import __version__ import hashlib diff --git a/ceda_elasticsearch_tools/cmdline/update_md5.py b/ceda_elasticsearch_tools/cmdline/update_md5.py index 41cb4e5..8cb28ca 100644 --- a/ceda_elasticsearch_tools/cmdline/update_md5.py +++ b/ceda_elasticsearch_tools/cmdline/update_md5.py @@ -33,12 +33,12 @@ from ceda_elasticsearch_tools.core import log_reader from datetime import datetime import os, logging -from ceda_elasticsearch_tools.cmdline import __version__ +from ceda_elasticsearch_tools import __version__ import subprocess import simplejson as json from ceda_elasticsearch_tools.core.updater import ElasticsearchUpdater import math -from ceda_elasticsearch_tools.core.util import ProgressBar +from ceda_elasticsearch_tools.core.utils import ProgressBar def logger_setup(log_dir): diff --git a/ceda_elasticsearch_tools/core/log_reader.py b/ceda_elasticsearch_tools/core/log_reader.py index 71aa23d..2e5c05a 100644 --- a/ceda_elasticsearch_tools/core/log_reader.py +++ b/ceda_elasticsearch_tools/core/log_reader.py @@ -3,10 +3,9 @@ import re import hashlib from datetime import datetime -from ceda_elasticsearch_tools.core.utils import get_latest_log - import logging +from ceda_elasticsearch_tools.core.utils import get_latest_log class SpotMapping(object): """ diff --git a/ceda_elasticsearch_tools/core/updater.py b/ceda_elasticsearch_tools/core/updater.py index 1464ae2..55e16a1 100644 --- a/ceda_elasticsearch_tools/core/updater.py +++ b/ceda_elasticsearch_tools/core/updater.py @@ -2,10 +2,11 @@ import json import re import logging -from .log_reader import MD5LogFile -import utils import hashlib + from ceda_elasticsearch_tools.elasticsearch import CEDAElasticsearchClient +from .log_reader import MD5LogFile +from . import utils class ElasticsearchQuery(object): """