Replace deprecated functions in datetime
The datetime.utcfromtimestamp() and datetime.utcnow() are deprecated in Python 3.12. Replace datetime.utcfromtimestamp() with datetime.fromtimestamp(). Replace datetime.utcnow() with oslo_utils.timeutils.utcnow(). This bumps oslo.utils to 7.0.0. Change-Id: Ifa8a892aeaece7575a29c979bf48a1c27ec1643f Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
parent
d3c4ffe496
commit
906be85853
@ -15,6 +15,7 @@ import decimal
|
|||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -186,5 +187,4 @@ def format_value(value):
|
|||||||
|
|
||||||
|
|
||||||
def one_year_from_now():
|
def one_year_from_now():
|
||||||
now = datetime.datetime.utcnow()
|
return timeutils.utcnow() + datetime.timedelta(days=365)
|
||||||
return now + datetime.timedelta(days=365)
|
|
||||||
|
@ -198,7 +198,9 @@ def swift_get_container(request, container_name, with_data=False):
|
|||||||
parameters = parse.quote(container_name.encode('utf8'))
|
parameters = parse.quote(container_name.encode('utf8'))
|
||||||
public_url = swift_endpoint + '/' + parameters
|
public_url = swift_endpoint + '/' + parameters
|
||||||
ts_float = float(headers.get('x-timestamp'))
|
ts_float = float(headers.get('x-timestamp'))
|
||||||
timestamp = datetime.utcfromtimestamp(ts_float).isoformat()
|
timestamp = datetime.fromtimestamp(
|
||||||
|
ts_float, tz=datetime.timezone.utc).replace(
|
||||||
|
tzinfo=None).isoformat()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
container_info = {
|
container_info = {
|
||||||
@ -411,7 +413,9 @@ def swift_get_object(request, container_name, object_name, with_data=True,
|
|||||||
timestamp = None
|
timestamp = None
|
||||||
try:
|
try:
|
||||||
ts_float = float(headers.get('x-timestamp'))
|
ts_float = float(headers.get('x-timestamp'))
|
||||||
timestamp = datetime.utcfromtimestamp(ts_float).isoformat()
|
timestamp = datetime.fromtimestamp(
|
||||||
|
ts_float, tz=datetime.timezone.utc).replace(
|
||||||
|
tzinfo=None).isoformat()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
obj_info = {
|
obj_info = {
|
||||||
|
@ -19,7 +19,7 @@ oslo.i18n>=5.1.0 # Apache-2.0
|
|||||||
oslo.policy>=3.11.0 # Apache-2.0
|
oslo.policy>=3.11.0 # Apache-2.0
|
||||||
oslo.serialization>=4.3.0 # Apache-2.0
|
oslo.serialization>=4.3.0 # Apache-2.0
|
||||||
oslo.upgradecheck>=1.5.0 # Apache-2.0
|
oslo.upgradecheck>=1.5.0 # Apache-2.0
|
||||||
oslo.utils>=4.12.0 # Apache-2.0
|
oslo.utils>=7.0.0 # Apache-2.0
|
||||||
osprofiler>=3.4.2 # Apache-2.0
|
osprofiler>=3.4.2 # Apache-2.0
|
||||||
pyScss>=1.4.0 # MIT License
|
pyScss>=1.4.0 # MIT License
|
||||||
python-cinderclient>=8.0.0 # Apache-2.0
|
python-cinderclient>=8.0.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user