Remove timeutils.strtime() usage

This patch remove strtime() usage as it's going to be deprecated in
oslo_utils (see I8b5119e64369ccac3423dccc04421f99912df733).

Change-Id: Ida6f35d9c30e9b96370c62c56e1e2e2bd005ceea
This commit is contained in:
Julien Danjou 2015-03-18 10:28:09 +01:00
parent 91d918ab2f
commit 5b7629dba0
2 changed files with 6 additions and 3 deletions

View File

@ -157,7 +157,8 @@ class GuruMeditation(object):
service_name = service_name or os.path.basename(
inspect.stack()[-1][1])
filename = "%s_gurumeditation_%s" % (
service_name, timeutils.strtime(fmt=cls.timestamp_fmt))
service_name, timeutils.utcnow().strftime(
cls.timestamp_fmt))
filepath = os.path.join(log_dir, filename)
try:
with open(filepath, "w") as dumpfile:

View File

@ -14,6 +14,7 @@
from __future__ import print_function
import datetime
import os
import re
import signal
@ -167,7 +168,8 @@ class TestGuruMeditationReport(base.BaseTestCase):
os.kill(os.getpid(), signal.SIGUSR1)
self.assertIn('Guru Meditation', sys.stderr.getvalue())
@mock.patch('oslo_utils.timeutils.strtime', return_value="NOW")
@mock.patch('oslo_utils.timeutils.utcnow',
return_value=datetime.datetime(2014, 1, 1, 12, 0, 0))
def test_register_autorun_log_dir(self, mock_strtime):
log_dir = self.useFixture(fixtures.TempDir()).path
gmr.TextGuruMeditation.setup_autorun(
@ -175,7 +177,7 @@ class TestGuruMeditationReport(base.BaseTestCase):
os.kill(os.getpid(), signal.SIGUSR1)
with open(os.path.join(
log_dir, "fake-service_gurumeditation_NOW")) as df:
log_dir, "fake-service_gurumeditation_20140101120000")) as df:
self.assertIn('Guru Meditation', df.read())
def tearDown(self):