2015-09-15 4:10 GMT+02:00 Jan Tluka <jtluka(a)redhat.com>:
Mon, Sep 14, 2015 at 08:26:40AM EDT, jprochaz(a)redhat.com wrote:
>2015-09-14 14:05 GMT+02:00 <olichtne(a)redhat.com>:
>
>> From: Ondrej Lichtner <olichtne(a)redhat.com>
>>
>> People from different time zones can use the same PerfRepo instance,
>> automatically using UTC time stamps will avoid incorrect sorting of
>> results (by date).
>>
>> Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
>> ---
>> lnst/Controller/PerfRepo.py | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lnst/Controller/PerfRepo.py b/lnst/Controller/PerfRepo.py
>> index e244321..4418902 100644
>> --- a/lnst/Controller/PerfRepo.py
>> +++ b/lnst/Controller/PerfRepo.py
>> @@ -121,7 +121,7 @@ class PerfRepoTestExecution(PerfRepoObject):
>> if type(xml) is NoneType:
>> self._id = None
>> self._name = None
>> - self._started = datetime.datetime.now().isoformat()
>> + self._started = datetime.datetime.utcnow().isoformat()
>> self._testId = None
>> self._testUid = None
>> self._comment = ""
>> @@ -173,7 +173,7 @@ class PerfRepoTestExecution(PerfRepoObject):
>>
>> def set_started(self, date=None):
>> if isinstance(date, NoneType):
>> - date = datetime.datetime.now()
>> + date = datetime.datetime.utcnow().isoformat()
>> self._started = date.isoformat()
>>
>
>isoformat() returns type str, so execution fails on AttributeError
>exception
>Either don't call isoformat() on line with utcnow() or on the line below
>
>
>
Hmm, I don't see that problem on my setup. With which python version do
you see that?
Python 2.7.8 (default, Jul 5 2015, 14:16:16)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license"
for more information.
>>> import datetime
>>> a = datetime.datetime.now().isoformat()
>>> b = datetime.datetime.utcnow().isoformat()
>>> a
'2015-09-14T22:06:13.488851'
>>> b
'2015-09-15T02:06:20.313035'
The problem is not with utcnow() but with isoformat() called twice, second
time on str object, see this:
Python 2.7.10 (default, Jul 5 2015, 14:15:43)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license"
for more information.
>> import datetime
>> date = datetime.datetime.utcnow().isoformat()
>> started = date.isoformat()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'isoformat'
>> else:
>> self._started = date
>> --
>> 2.5.2
>>
>> _______________________________________________
>> LNST-developers mailing list
>> LNST-developers(a)lists.fedorahosted.org
>>
https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
>>
>
>
>
>--
>Best regards,
>
>Jiri Prochazka
>LNST Developer
>|
www.lnst-project.org
>
>+420 532 294 633 | jprochaz(a)redhat.com
>Red Hat Czech | Purkyňova 71/99, 612 00 Brno
>_______________________________________________
>LNST-developers mailing list
>LNST-developers(a)lists.fedorahosted.org
>https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
--
Best regards,
Jiri Prochazka
LNST Developer
|
www.lnst-project.org
+420 532 294 633 | jprochaz(a)redhat.com
Red Hat Czech | Purkyňova 71/99, 612 00 Brno