Merge "Replace deprecated datetime.datetime.utcnow"
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
#
|
||||
|
||||
import abc
|
||||
import datetime as dt
|
||||
import datetime
|
||||
import textwrap
|
||||
|
||||
from osc_lib.command import command
|
||||
from oslo_utils import timeutils
|
||||
|
||||
|
||||
DEFAULT_LIMIT = 100
|
||||
@@ -204,24 +205,24 @@ def get_duration_str(start_dt_str, end_dt_str):
|
||||
if not start_dt_str:
|
||||
return ''
|
||||
|
||||
start_dt = dt.datetime.strptime(start_dt_str, '%Y-%m-%d %H:%M:%S')
|
||||
start_dt = datetime.datetime.strptime(start_dt_str, '%Y-%m-%d %H:%M:%S')
|
||||
|
||||
if end_dt_str:
|
||||
end_dt = dt.datetime.strptime(end_dt_str, '%Y-%m-%d %H:%M:%S')
|
||||
end_dt = datetime.datetime.strptime(end_dt_str, '%Y-%m-%d %H:%M:%S')
|
||||
|
||||
return str(end_dt - start_dt)
|
||||
|
||||
delta_from_now = dt.datetime.utcnow() - start_dt
|
||||
delta_from_now = timeutils.utcnow() - start_dt
|
||||
|
||||
# If delta is too small then we won't show any value. It means that
|
||||
# the corresponding process (e.g. an execution) just started.
|
||||
if delta_from_now < dt.timedelta(seconds=2):
|
||||
if delta_from_now < datetime.timedelta(seconds=2):
|
||||
return '...'
|
||||
|
||||
# Drop microseconds to decrease verbosity.
|
||||
delta = (
|
||||
delta_from_now
|
||||
- dt.timedelta(microseconds=delta_from_now.microseconds)
|
||||
- datetime.timedelta(microseconds=delta_from_now.microseconds)
|
||||
)
|
||||
|
||||
return "{}...".format(delta)
|
||||
|
@@ -13,13 +13,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
import os
|
||||
import tempfile
|
||||
from unittest import mock
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from oslo_utils import timeutils
|
||||
import yaml
|
||||
|
||||
from mistralclient.api.v2 import environments
|
||||
@@ -37,8 +36,8 @@ ENVIRONMENT_DICT = {
|
||||
'timeout': 600,
|
||||
'verbose': True
|
||||
},
|
||||
'created_at': str(datetime.datetime.utcnow()),
|
||||
'updated_at': str(datetime.datetime.utcnow())
|
||||
'created_at': str(timeutils.utcnow()),
|
||||
'updated_at': str(timeutils.utcnow())
|
||||
}
|
||||
|
||||
ENVIRONMENT = environments.Environment(mock, ENVIRONMENT_DICT)
|
||||
|
Reference in New Issue
Block a user