Skip to content

Commit

Permalink
PEP517
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaeno committed Jan 23, 2024
1 parent 63dd0eb commit c274dd4
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 73 deletions.
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion PandaPkgInfo.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = "0.0.45"
release_version = "0.1.0"
4 changes: 2 additions & 2 deletions pandacommon/pandalogger/LogWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions pandacommon/pandamsgbkr/msg_bkr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from Queue import Empty, Queue

import stomp

from pandacommon.pandalogger import logger_utils

# logger
Expand Down Expand Up @@ -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()
Expand All @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions pandacommon/pandautils/thread_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package/pyproject.toml → pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

53 changes: 0 additions & 53 deletions setup.py

This file was deleted.

0 comments on commit c274dd4

Please sign in to comment.