#2075 Don't use datetime timestamp() as it's not in Python 2
Merged 4 years ago by tkopecek. Opened 4 years ago by adamwill.
adamwill/koji no-timestamp-py2  into  master

file modified
+2 -1
@@ -1,4 +1,5 @@ 

  #import koji

+ #import koji.util as kojiutil

  #from kojiweb import util

  #from six.moves.urllib.parse import quote

  #import datetime
@@ -97,7 +98,7 @@ 

      #set $end_ts = $task.completion_ts

      #end if

      #if not $end_ts

-     #set $end_ts = datetime.datetime.utcnow().timestamp()

+     #set $end_ts = $kojiutil.parseTime($kojiutil.encode_datetime(datetime.datetime.utcnow()))

      #end if

      <tr>

        <th title="From task's creation">Total time</th>

The timestamp() method for datetime.datetime instances was
only added in Python 3. It does not exist in Python 2. So we
can't safely use it here.

I believe this should do the right thing, taking advantage of a
couple of existing utility functions in koji.util.

Signed-off-by: Adam Williamson awilliam@redhat.com

@kevin monkeypatched the Fedora instance with this patch and it seems to be working, I'm seeing apparently-sane 'Total time' and 'Task time' values for running tasks and a distinct lack of tracebacks :)

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

4 years ago

Commit d7fc15b fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago

Commit d7fc15b fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

4 years ago