From 5b7629dba0422683721005f2e1ba3913ddaf9d78 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 18 Mar 2015 10:28:09 +0100 Subject: [PATCH] Remove timeutils.strtime() usage This patch remove strtime() usage as it's going to be deprecated in oslo_utils (see I8b5119e64369ccac3423dccc04421f99912df733). Change-Id: Ida6f35d9c30e9b96370c62c56e1e2e2bd005ceea --- openstack/common/report/guru_meditation_report.py | 3 ++- tests/unit/reports/test_guru_meditation_report.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openstack/common/report/guru_meditation_report.py b/openstack/common/report/guru_meditation_report.py index 5c370ec..bff9234 100644 --- a/openstack/common/report/guru_meditation_report.py +++ b/openstack/common/report/guru_meditation_report.py @@ -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: diff --git a/tests/unit/reports/test_guru_meditation_report.py b/tests/unit/reports/test_guru_meditation_report.py index bc846a4..68e8ea5 100644 --- a/tests/unit/reports/test_guru_meditation_report.py +++ b/tests/unit/reports/test_guru_meditation_report.py @@ -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):