From c274dd4cbf867e5df21a2513c9ea90c5e2cccfea Mon Sep 17 00:00:00 2001 From: tmaeno Date: Tue, 23 Jan 2024 16:10:40 +0100 Subject: [PATCH] PEP517 --- .pre-commit-config.yaml | 2 - ChangeLog.txt | 4 +- PandaPkgInfo.py | 2 +- pandacommon/pandalogger/LogWrapper.py | 4 +- pandacommon/pandamsgbkr/msg_bkr_utils.py | 8 +++- pandacommon/pandautils/thread_utils.py | 4 +- package/pyproject.toml => pyproject.toml | 2 +- setup.cfg | 8 ---- setup.py | 53 ------------------------ 9 files changed, 14 insertions(+), 73 deletions(-) rename package/pyproject.toml => pyproject.toml (98%) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ac179e..5f65fdf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,11 +5,9 @@ repos: hooks: - id: black types: [python] - args: ["--config", "package/pyproject.toml"] - repo: https://github.com/pycqa/isort rev: 5.12.0 hooks: - id: isort name: isort (python) - args: ["--settings-path", "package/pyproject.toml"] diff --git a/ChangeLog.txt b/ChangeLog.txt index 5b180ba..e0ee334 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,8 @@ Release Notes ------------- -* current - * utcnow() -> now(UTC) +* 0.1.0 (23/1/2024) + * utcnow() -> datetime.now(datetime.timezone.utc).replace(tzinfo=None) * PEP517 * 0.0.45 (09/10/2023) diff --git a/PandaPkgInfo.py b/PandaPkgInfo.py index 746a246..6e386ba 100644 --- a/PandaPkgInfo.py +++ b/PandaPkgInfo.py @@ -1 +1 @@ -release_version = "0.0.45" +release_version = "0.1.0" diff --git a/pandacommon/pandalogger/LogWrapper.py b/pandacommon/pandalogger/LogWrapper.py index 8391d74..3e0a21c 100644 --- a/pandacommon/pandalogger/LogWrapper.py +++ b/pandacommon/pandalogger/LogWrapper.py @@ -9,7 +9,7 @@ class LogWrapper: def __init__(self, log, prefix="", lineLimit=100, monToken=None, seeMem=False, hook=None): # use timestamp as prefix if prefix is None: - self.prefix = datetime.datetime.utcnow().isoformat("/") + self.prefix = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat("/") else: self.prefix = prefix # logger instance @@ -37,7 +37,7 @@ def keepMsg(self, msg): # keep max message depth if len(self.msg_buffer) > self.line_limit: self.msg_buffer.pop(0) - timeNow = datetime.datetime.utcnow() + timeNow = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) self.msg_buffer.append("{0} : {1}".format(timeNow.isoformat(" "), msg)) def debug(self, msg): diff --git a/pandacommon/pandamsgbkr/msg_bkr_utils.py b/pandacommon/pandamsgbkr/msg_bkr_utils.py index 551db3f..d96209b 100644 --- a/pandacommon/pandamsgbkr/msg_bkr_utils.py +++ b/pandacommon/pandamsgbkr/msg_bkr_utils.py @@ -17,6 +17,7 @@ from Queue import Empty, Queue import stomp + from pandacommon.pandalogger import logger_utils # logger @@ -719,7 +720,10 @@ def add_remover(self, headers, timeout): # unique id for each remover r_id = self.sub_id + "." + str(uuid.uuid4()) with self.remover_lock: - self.removers[r_id] = {"timeout": datetime.datetime.utcnow() + datetime.timedelta(seconds=timeout), "headers": copy.copy(headers)} + self.removers[r_id] = { + "timeout": datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) + datetime.timedelta(seconds=timeout), + "headers": copy.copy(headers), + } # reconnect if necessary if self.got_disconnected: self.restart() @@ -733,7 +737,7 @@ def purge_removers(self): """ self.logger.debug("purging old removers") with self.remover_lock: - time_now = datetime.datetime.utcnow() + time_now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) n_old = len(self.removers) for r_id in list(self.removers): timeout = self.removers[r_id]["timeout"] diff --git a/pandacommon/pandautils/thread_utils.py b/pandacommon/pandautils/thread_utils.py index 0c0c27c..d544a9e 100644 --- a/pandacommon/pandautils/thread_utils.py +++ b/pandacommon/pandautils/thread_utils.py @@ -67,14 +67,14 @@ def __getitem__(self, item): def __setitem__(self, item, value): with self.lock: - dict.__setitem__(self, item, {"time_stamp": datetime.datetime.utcnow(), "data": value}) + dict.__setitem__(self, item, {"time_stamp": datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None), "data": value}) # check data by taking freshness into account def __contains__(self, item): with self.lock: try: ret = dict.__getitem__(self, item) - if ret["time_stamp"] > datetime.datetime.utcnow() - datetime.timedelta(minutes=self.timeout): + if ret["time_stamp"] > datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) - datetime.timedelta(minutes=self.timeout): return True except Exception: pass diff --git a/package/pyproject.toml b/pyproject.toml similarity index 98% rename from package/pyproject.toml rename to pyproject.toml index a307c54..68ff69a 100644 --- a/package/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "requests", "stomp.py >=4.1.23, <=7.0.0", ] - +requires-python = ">=3.8" [project.urls] Homepage = "https://panda-wms.readthedocs.io/en/latest/" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c837ce7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,8 +0,0 @@ -[global] - -[bdist_rpm] -provides = panda-common -release = 1 -packager = Panda Team -requires = python - diff --git a/setup.py b/setup.py deleted file mode 100644 index bea7a14..0000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -# -# Setup prog for Panda Common -# -# -# set PYTHONPATH to use the current directory first -import sys - -sys.path.insert(0, ".") # noqa: E402 - -import os - -import PandaPkgInfo -from setuptools import find_packages, setup -from setuptools.command.install import install as install_org - -# get release version -release_version = PandaPkgInfo.release_version -if "BUILD_NUMBER" in os.environ: - release_version = "{0}.{1}".format(release_version, os.environ["BUILD_NUMBER"]) - - -# custom install to disable egg -class install_panda(install_org): - def finalize_options(self): - install_org.finalize_options(self) - self.single_version_externally_managed = True - - -setup( - name="panda-common", - version=release_version, - description=" PanDA Common Package", - long_description="""This package contains PanDA Common Components""", - license="GPL", - author="Panda Team", - author_email="atlas-adc-panda@cern.ch", - url="https://twiki.cern.ch/twiki/bin/view/Atlas/PanDA", - packages=find_packages(), - install_requires=[ - "configparser", - "pytz", - "stomp.py >=4.1.23, <=7.0.0", - "requests", - ], - data_files=[ - ("etc/panda", ["templates/panda_common.cfg.rpmnew"]), - ], - scripts=["tools/panda_common-install_igtf_ca"], - cmdclass={ - "install": install_panda, - }, -)